国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

asp.net下Cache 緩存操作類代碼

2020-01-18 00:42:13
字體:
來源:轉載
供稿:網友
復制代碼 代碼如下:

using System.Collections.Generic;
using System.Web;
using System;
namespace DataAccess
{
/// <summary>
/// 緩存控制類
/// </summary>
public class CacheControl
{
public static List<string> AllUseCacheKey = new List<string>();
/// <summary>
/// 添加緩存
/// </summary>
/// <param name="key"></param>
/// <param name="value"></param>
/// <param name="absoluteExpiration"></param>
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);
}
/// <summary>
/// 移除緩存
/// </summary>
/// <param name="key"></param>
public static void RemoveCache(string key)
{
if (AllUseCacheKey.Contains(key))
{
AllUseCacheKey.Remove(key);
}
HttpContext.Current.Cache.Remove(key);
}
/// <summary>
/// 清空使用的緩存
/// </summary>
public static void ClearCache()
{
foreach (string value in AllUseCacheKey)
{
HttpContext.Current.Cache.Remove(value);
}
AllUseCacheKey.Clear();
}
}
}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 乌鲁木齐市| 航空| 青川县| 历史| 防城港市| 澄迈县| 波密县| 新宾| 射洪县| 神农架林区| 祁东县| 德阳市| 德格县| 资源县| 团风县| 樟树市| 彭水| 台州市| 西乌珠穆沁旗| 邹城市| 新乐市| 平南县| 攀枝花市| 安陆市| 普洱| 徐水县| 哈尔滨市| 都江堰市| 扶沟县| 治县。| 金华市| 讷河市| 宜兴市| 敦煌市| 修文县| 鹿泉市| 高阳县| 和田市| 清河县| 玛沁县| 苗栗县|