rt
类库中无法直接引用System.Web.Cacheing,HttpRuntime.Cache等没法使用,不使用哈希表,有什么方法使用cache吗?
类库中无法直接引用System.Web.Cacheing,HttpRuntime.Cache等没法使用,不使用哈希表,有什么方法使用cache吗?
解决方案 »
- 初学者向高手请教:按钮控件
- 关于静态页面生成原理
- 关于detailview删除前确认问题
- GridView 中嵌套GridView 的问题
- 求教一个使用GDI或者GDI+画线性图的实例
- 请问高手,在vs.net b/s 系统如何实现定位打印,我的打印机是钟式打印机
- css
- 我有一个第三方的控件(ocx),如何将其制作成可以自动下载注册的cab包
- TextBox控件怎样设置才能让她从右边开始输入,急!在线等候
- 如何控制Web控件的位置,比如我要移动一TextBox的位置?100分
- 问一个技术性问题,.net静态列表的问题
- System.Web.Caching.Cache 与 HttpRuntime.Cache 有什么区别?
或者用的别的类库 如memcache等
using System.Web;
using System.Collections.Generic;
using System.Web.Caching;
using System.Text;
using System.Collections;namespace Common
{
public class MyCache
{
public static object ReadCacheValue(string eCacheKey)
{
if (HttpContext.Current != null && HttpContext.Current.Cache != null)
{
return HttpContext.Current.Cache[eCacheKey];
}else
{
return null;
}
} public static void AddCache(string eCacheKey, object eCacheValue, double eCacheMin)
{
HttpContext.Current.Cache.Insert(eCacheKey, eCacheValue, null, DateTime.Now.AddMinutes(eCacheMin),
Cache.NoSlidingExpiration);
} public static void ClearCache()
{
System.Web.Caching.Cache _cache = HttpRuntime.Cache;
IDictionaryEnumerator CacheEnum = _cache.GetEnumerator();
ArrayList al = new ArrayList();
while (CacheEnum.MoveNext())
{
al.Add(CacheEnum.Key);
} foreach (string key in al)
{
_cache.Remove(key);
} }
}
}