首页 > 代码库 > 基本类-SystemCache
基本类-SystemCache
简单的通过.net K-V形式操作Cache:
public enum CacheKey { LanguageQueryProcess_FetchAll, ProjectQueryProcess_FetchAll } public class SystemCache { /// <summary> /// HttpContext.Current.Cache.Insert(string key, object value, CacheDependency dependencies, DateTime absoluteExpiration, TimeSpan slidingExpiration) /// Set cache /// /// default 20 minutes /// </summary> /// <param name="key"></param> /// <param name="value"></param> public static void SetCache(CacheKey key, object value, int expirationMinutes = 20) { DateTime expirationTime = DateTime.Now.AddMinutes(expirationMinutes); HttpContext.Current.Cache.Insert( key.ToString() , value , null , expirationTime , TimeSpan.Zero ); } /// <summary> /// get cache /// </summary> /// <param name="key"></param> /// <returns></returns> public static object GetCache(CacheKey key) { object value = http://www.mamicode.com/HttpContext.Current.Cache.Get(key.ToString());>
基本类-SystemCache
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。