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

首頁(yè) > 編程 > C# > 正文

c#自帶緩存使用方法 c#移除清理緩存

2020-01-24 02:48:52
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

復(fù)制代碼 代碼如下:

/// <summary>
/// 獲取數(shù)據(jù)緩存
/// </summary>
/// <param name="CacheKey">鍵</param>
public static object GetCache(string CacheKey)
{
    System.Web.Caching.Cache objCache = HttpRuntime.Cache;
    return objCache[CacheKey];
}
/// <summary>
/// 設(shè)置數(shù)據(jù)緩存
/// </summary>
public static void SetCache(string CacheKey, object objObject)
{
    System.Web.Caching.Cache objCache = HttpRuntime.Cache;
    objCache.Insert(CacheKey, objObject);
}
/// <summary>
/// 設(shè)置數(shù)據(jù)緩存
/// </summary>
public static void SetCache(string CacheKey, object objObject, TimeSpan Timeout)
{
    System.Web.Caching.Cache objCache = HttpRuntime.Cache;
    objCache.Insert(CacheKey, objObject, null, DateTime.MaxValue, Timeout, System.Web.Caching.CacheItemPriority.NotRemovable, null);
}
/// <summary>
/// 設(shè)置數(shù)據(jù)緩存
/// </summary>
public static void SetCache(string CacheKey, object objObject, DateTime absoluteExpiration, TimeSpan slidingExpiration)
{
    System.Web.Caching.Cache objCache = HttpRuntime.Cache;
    objCache.Insert(CacheKey, objObject, null, absoluteExpiration, slidingExpiration);
}
/// <summary>
/// 移除指定數(shù)據(jù)緩存
/// </summary>
public static void RemoveAllCache(string CacheKey)
{
    System.Web.Caching.Cache _cache = HttpRuntime.Cache;
    _cache.Remove(CacheKey);
}
/// <summary>
/// 移除全部緩存
/// </summary>
public static void RemoveAllCache()
{
    System.Web.Caching.Cache _cache = HttpRuntime.Cache;
    IDictionaryEnumerator CacheEnum = _cache.GetEnumerator();
    while (CacheEnum.MoveNext())
    {
_cache.Remove(CacheEnum.Key.ToString());
    }
}

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 芦溪县| 昌都县| 甘谷县| 错那县| 邵东县| 桐乡市| 施秉县| 台东县| 阿瓦提县| 马关县| 蓝山县| 宿州市| 离岛区| 上林县| 德州市| 巨鹿县| 南阳市| 洛浦县| 惠州市| 辛集市| 乐亭县| 肇源县| 资中县| 丁青县| 宾阳县| 湛江市| 长宁县| 吉水县| 昌平区| 延边| 平舆县| 当雄县| 会东县| 聂拉木县| 汨罗市| 漾濞| 吴川市| 什邡市| 腾冲县| 大理市| 宝鸡市|