using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Collections; namespace Common
{
public static class CacheManager
{ /// <summary>
/// 获取数据缓存
/// </summary>
/// <param name="CacheKey">键</param>
public static object GetCache(string CacheKey)
{
System.Web.Caching.Cache objCache = HttpRuntime.Cache;
return objCache[CacheKey];
} /// <summary>
/// 设置数据缓存
/// </summary>
public static void SetCache(string CacheKey, object objObject)
{
System.Web.Caching.Cache objCache = HttpRuntime.Cache;
objCache.Insert(CacheKey, objObject);
} /// <summary>
/// 设置数据缓存
/// CacheKey
/// objObject
/// expires 分钟
/// </summary>
public static void SetCache(string CacheKey, object objObject, int expires)
{
System.Web.Caching.Cache objCache = HttpRuntime.Cache;
objCache.Insert(CacheKey, objObject, null, DateTime.MaxValue, new TimeSpan(, expires, ), System.Web.Caching.CacheItemPriority.NotRemovable, null);
} /// <summary>
/// 设置数据缓存
/// </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>
/// 移除指定数据缓存
/// </summary>
public static void RemoveCache(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());
}
}
}
}

最新文章

  1. Vertical Menu ver4
  2. iOS 自定义方法 - UIView扩展
  3. 【codevs】刷题记录→_→(推荐看!)
  4. Oracle层次查询
  5. Android基于mAppWidget实现手绘地图(一)--简介
  6. [BZOJ1177][Apio2009]Oil
  7. SPI的工作模式口诀[转]
  8. Android学习笔记(2)
  9. ajaxFileUpload - Post file and data together
  10. Python for 循环 失效
  11. ThinkPHP实现RBAC
  12. group_concat()函数总结
  13. js筛选
  14. python_特殊函数
  15. 分布式系列六: WebService简介
  16. Codeforces Round #502 (in memory of Leopoldo Taravilse, Div. 1 + Div. 2)
  17. BootStrap学习(3)_导航菜单
  18. Windows10系统重置网络设置
  19. RPG游戏中如何判断敌人是否在玩家的攻击范围之内
  20. go中的无限极分类的问题

热门文章

  1. HDU——1061Rightmost Digit(高次方,找规律)
  2. [SCOI2008]配对 (贪心,动态规划)
  3. [POI2007]MEG-Megalopolis (树状数组,Dfs序)
  4. [暑假集训--数位dp]hdu3709 Balanced Number
  5. IOs动画的那些事儿
  6. codeforces 900D 数论+组合+容斥原理
  7. Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
  8. Linux 之 CentOS练习
  9. c#学习笔记之Application.DoEvents应用
  10. (1)sqlite基础