asp.Net下Cacheキャッシュ操作クラスコード
1492 ワード
using System.Collections.Generic;
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();
}
}
}