zoukankan      html  css  js  c++  java
  • Code-Helper-Web:CacheHelper.cs

    ylbtech-Code-Helper-Web:CacheHelper.cs
    1.返回顶部
    1、
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Web;
    using System.Collections;
    
    namespace Core.WebHelper
    {
        /// <summary>
        /// 缓存辅助类
        /// </summary>
        public class CacheHelper
        {
            /// <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>
            /// 设置数据缓存
            /// </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>
            /// 设置数据缓存
            /// </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 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());
                }
            }
        }
    }
    2、
    2.返回顶部
     
    3.返回顶部
     
    4.返回顶部
     
    5.返回顶部
     
     
    6.返回顶部
     
    warn 作者:ylbtech
    出处:http://ylbtech.cnblogs.com/
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    招聘、外包和求职;找人、找活和找工作的都来看看。
    这周我加星(6)
    走出行业暴利思维,开始为“软件”付钱!
    真相,道歉。
    这周我加星(8-11)
    独家:Havok 发布新的 AI 中间件
    一奖三年得,终获 CSDN MVB,与大家分享喜悦
    “解决”OpenCASCADE图形设备初始化问题
    如何在Debian上安装ATI官方驱动
    VC++/MFC学习笔记(六)
  • 原文地址:https://www.cnblogs.com/storebook/p/12676189.html
Copyright © 2011-2022 走看看