当前位置:   article > 正文

数据缓存类_缓存类存放数据

缓存类存放数据
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Web;
  6. namespace Common
  7. {
  8. /// <summary>
  9. /// 数据缓存类
  10. /// </summary>
  11. public class DataCache
  12. {
  13. /// <summary>
  14. /// 获取缓存
  15. /// </summary>
  16. /// <param name="CacheKey"></param>
  17. /// <returns></returns>
  18. public static object GetCache(string CacheKey)
  19. {
  20. return HttpRuntime.Cache[CacheKey];
  21. }
  22. /// <summary>
  23. /// 设置缓存
  24. /// </summary>
  25. /// <param name="CacheKey"></param>
  26. /// <param name="objObject"></param>
  27. public static void SetCache(string CacheKey, object objObject)
  28. {
  29. HttpRuntime.Cache.Insert(CacheKey, objObject);
  30. }
  31. /// <summary>
  32. /// 设置缓存
  33. /// </summary>
  34. /// <param name="CacheKey"></param>
  35. /// <param name="objObject"></param>
  36. /// <param name="absoluteExpiration"></param>
  37. /// <param name="slidingExpiration"></param>
  38. public static void SetCache(string CacheKey, object objObject, DateTime absoluteExpiration, TimeSpan slidingExpiration)
  39. {
  40. HttpRuntime.Cache.Insert(CacheKey, objObject, null, absoluteExpiration, slidingExpiration);
  41. }
  42. }
  43. }


声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/228650
推荐阅读
相关标签
  

闽ICP备14008679号