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

首頁 > 編程 > .NET > 正文

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

2024-07-10 13:25:00
字體:
來源:轉載
供稿:網友

復制代碼 代碼如下:


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></param>
/// <param></param>
/// <param></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></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();
}
}
}

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 鄂托克前旗| 阳谷县| 竹溪县| 克东县| 团风县| 沅江市| 洪泽县| 山西省| 海伦市| 灵宝市| 广德县| 邻水| 翁牛特旗| 黄冈市| 儋州市| 聊城市| 甘谷县| 本溪市| 沙田区| 玉田县| 如东县| 遂昌县| 昂仁县| 绥棱县| 天等县| 柳林县| 京山县| 理塘县| 岳阳市| 玛曲县| 偃师市| 措勤县| 广元市| 方城县| 绩溪县| 泸西县| 庄浪县| 周口市| 清丰县| 黄龙县| 兰西县|