摘要:Cache的應用
//---------------------- 設定 ---------------------------------------------------------------------
public static void SetCache(string _Key, object _Value, int _Minute)
{
HttpContext oContext = HttpContext.Current;
SetCache(oContext, _Key, _Value, _Minute);
}
public static void SetCache(HttpContext oContext, string _Key, object _Value, int _Minute)
{
oContext.Cache.Insert(_Key, _Value, null, DateTime.Now.AddMinutes(_Minute), TimeSpan.Zero);
}
//----------------------- 取得 ---------------------------------------------------------
public static object GetCache(HttpContext oContext, string _Key)
{
return oContext.Cache.Get(_Key);
}
public static object GetCache( string _Key)
{
HttpContext oContext = HttpContext.Current;
return GetCache(oContext, _Key);
}
//----------------------- 刪 除 -----------------------------------------------------
public static void RemoveCache(HttpContext oContext, string _Key)
{
oContext.Cache.Remove(_Key);
}
public static void RemoveCache( string _Key)
{
HttpContext oContext = HttpContext.Current;
RemoveCache(oContext,_Key);
}