Command_DataCache.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*******************************************************************************
  2. * iNethinkCMS - 网站内容管理系统
  3. * Copyright (C) 2012-2013 inethink.com
  4. *
  5. * @author jackyang <69991000@qq.com>
  6. * @website http://cms.inethink.com
  7. * @version 1.3.6.0 (2013-08-14)
  8. *
  9. * This is licensed under the GNU LGPL, version 3.0 or later.
  10. * For details, see: http://www.gnu.org/licenses/gpl-3.0.html
  11. *******************************************************************************/
  12. using System;
  13. using System.Web;
  14. namespace iNethinkCMS.Command
  15. {
  16. public class Command_DataCache
  17. {
  18. /// <summary>
  19. /// 获取当前应用程序指定CacheKey的Cache值
  20. /// </summary>
  21. /// <param name="CacheKey"></param>
  22. /// <returns></returns>
  23. public static object GetCache(string CacheKey)
  24. {
  25. System.Web.Caching.Cache objCache = HttpRuntime.Cache;
  26. return objCache[CacheKey];
  27. }
  28. /// <summary>
  29. /// 设置当前应用程序指定CacheKey的Cache值
  30. /// </summary>
  31. /// <param name="CacheKey"></param>
  32. /// <param name="objObject"></param>
  33. public static void SetCache(string CacheKey, object objObject)
  34. {
  35. System.Web.Caching.Cache objCache = HttpRuntime.Cache;
  36. objCache.Insert(CacheKey, objObject);
  37. }
  38. /// <summary>
  39. /// 设置当前应用程序指定CacheKey的Cache值
  40. /// </summary>
  41. /// <param name="CacheKey"></param>
  42. /// <param name="objObject"></param>
  43. public static void SetCache(string CacheKey, object objObject, DateTime absoluteExpiration, TimeSpan slidingExpiration)
  44. {
  45. System.Web.Caching.Cache objCache = HttpRuntime.Cache;
  46. objCache.Insert(CacheKey, objObject, null, absoluteExpiration, slidingExpiration);
  47. }
  48. }
  49. }