代码:
using System; System.Collections.Generic; System.Linq; System.Text; System.Web; namespace Common.Utils { /// <summary> /// 缓存 </summary> public static class CacheHelper { <summary> 获取缓存 </summary> object Get(string cacheKey) { return HttpRuntime.Cache[cacheKey]; } 设置缓存 void Set(string cacheKey,object value) { HttpRuntime.Cache.Insert(cacheKey,value); } 添加缓存 void Set<T>( value) { Type type = typeof(T); string tableName = type.Name; if (HttpRuntime.Cache[tableName] == null) { Dictionary<string,1)">object> dic = new Dictionary<object>(); dic.Add(cacheKey,value); HttpRuntime.Cache.Insert(tableName,dic); } else { Dictionary<object> dic = (Dictionary<)HttpRuntime.Cache[tableName]; if (dic.Keys.Contains<string>(cacheKey)) { dic[cacheKey] = value; } { dic.Add(cacheKey,value); } HttpRuntime.Cache[tableName] = dic; } } object Get<T>( cacheKey) { Type type = if (HttpRuntime.Cache[tableName] != (cacheKey)) { dic[cacheKey]; } } return ; } 删除缓存 void Remove<T>() { HttpRuntime.Cache.Remove((T).Name); } } }
原文地址:https://www.cnblogs.com/s0611163
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。