asp.net Cache 缓存操作类实现代码,需要的朋友可以参考下。
using System.Web;
using System;
namespace DataAccess
{
///
///
public class CacheControl
{
public static List AllUseCacheKey = new List();
///
///
///
///
///
public static void AddCache(string key, object value, DateTime absoluteExpiration)
{
if (!AllUseCacheKey.Contains(key))
{
AllUseCacheKey.Add(key);
}
HttpContext.Current.Cache.Add(key, value, null, absoluteExpiration, TimeSpan.Zero, System.Web.Caching.CacheItemPriority.Normal, null);
}
///
///
///
public static void RemoveCache(string key)
{
if (AllUseCacheKey.Contains(key))
{
AllUseCacheKey.Remove(key);
}
HttpContext.Current.Cache.Remove(key);
}
///
///
public static void ClearCache()
{
foreach (string value in AllUseCacheKey)
{
HttpContext.Current.Cache.Remove(value);
}
AllUseCacheKey.Clear();
}
}
}
以上就
来源gao!daima.com搞$代!码网
是asp.net下Cache 缓存操作类代码的详细内容,更多请关注gaodaima搞代码网其它相关文章!