zoukankan      html  css  js  c++  java
  • C# Cache的类方法

     public class DataCache
        {
            /// <summary>
            /// 获取当前应用程序指定CacheKey的Cache值
            /// </summary>
            /// <param name="CacheKey"></param>
            /// <returns></returns>
            public static object GetCache(string CacheKey)
            {
                System.Web.Caching.Cache objCache = HttpRuntime.Cache;
                return objCache[CacheKey];
            }

            /// <summary>
            /// 设置当前应用程序指定CacheKey的Cache值
            /// </summary>
            /// <param name="CacheKey"></param>
            /// <param name="objObject"></param>
            public static void SetCache(string CacheKey, object objObject)
            {
                System.Web.Caching.Cache objCache = HttpRuntime.Cache;
                objCache.Insert(CacheKey, objObject);
            }

            /// <summary>
            /// 移除指定数据缓存
            /// </summary>
            public static void RemoveCache(string CacheKey)
            {
                System.Web.Caching.Cache objCache = HttpRuntime.Cache;
                objCache.Remove(CacheKey);
            }

            /// <summary>
            /// 清空所有的Cache
            /// </summary>
            public static void RemoveAllCache()
            {
                List<string> cacheKeys = new List<string>();
                IDictionaryEnumerator cacheEnum = HttpContext.Current.Cache.GetEnumerator();
                while (cacheEnum.MoveNext())
                {
                    cacheKeys.Add(cacheEnum.Key.ToString());
                }
                foreach (string cacheKey in cacheKeys)
                {
                    HttpContext.Current.Cache.Remove(cacheKey);
                }
            }

        }

  • 相关阅读:
    shell脚本,文件里面的英文大小写替换方法。
    shell脚本,100以内的质数有哪些?
    shell脚本,当用sed删除某一文件里面的内容时,并追加到同一个文件会出现问题。
    shell脚本,按行读取文件的几种方法。
    shell脚本,锁机制
    shell脚本,通过一个shell程序计算n的阶乘。
    shell脚本,如何写进度条。
    shell脚本,判断给出的字符串是否相等。
    shell脚本,按空格开始60秒的倒计时。
    18:django 日志系统
  • 原文地址:https://www.cnblogs.com/DTWolf/p/4848465.html
Copyright © 2011-2022 走看看