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);
                }
            }

        }

  • 相关阅读:
    python操作MYSQL时防止SQL注入
    防止SQL注入的一些解决方法
    Gitbook 学习链接
    MySQL_编码utf8_bin和utf8_general_ci的区别
    使用linux脚本shell检查大数据各节点服务是否运行正常
    shell脚本监测elasticsearch集群节点
    Filebeat+Kafka+Logstash+ElasticSearch+Kibana搭建日志收集系统
    python中集合用法大全
    python常用内置函数
    跨模块全局变量的使用问题
  • 原文地址:https://www.cnblogs.com/DTWolf/p/4848465.html
Copyright © 2011-2022 走看看