zoukankan      html  css  js  c++  java
  • 缓存帮助类CacheHelper

    public class CacheHelper
        {
            //缓存容器 
            private static Dictionary<string, object> CacheDictionary = new Dictionary<string, object>();
            /// <summary>
            /// 添加缓存
            /// </summary>
            public static void Add(string key, object value)
            {
                CacheDictionary.Add(key, value);
            }
    
            /// <summary>
            /// 获取缓存
            /// </summary>
            public static T Get<T>(string key)
            {
                return (T)CacheDictionary[key];
            }
    
            /// <summary>
            /// 判断缓存是否存在
            /// </summary>
            /// <param name="key"></param>
            /// <returns></returns>
            public static bool Exsits(string key)
            {
                return CacheDictionary.ContainsKey(key);
            }
            /// <summary>
            /// 删除缓存
            /// </summary>
            /// <param name="key"></param>
            /// <returns></returns>
            public static bool Remove(string key)
            {
                return CacheDictionary.Remove(key);
            }
            /// <summary>
            /// 更新缓存
            /// </summary>
            public static void Update(string key, object value)
            {
                CacheDictionary.Remove(key);
                CacheDictionary.Add(key, value);
            }
        }
  • 相关阅读:
    980不同路径III
    输入函数
    IDEA更新maven依赖包
    join()函数
    方差偏差困境
    np.bincount()函数
    72编辑距离
    741摘樱桃
    523连续的子数组和
    1306跳跃游戏III
  • 原文地址:https://www.cnblogs.com/SmilePastaLi/p/11282912.html
Copyright © 2011-2022 走看看