zoukankan      html  css  js  c++  java
  • RedisCache 缓存

    /// <summary>
        /// 这是包装过公用的,用于本站而已。
        /// </summary>
        /// <author>rixiao</author>
        /// <date>2018-02-01</date>
        public class RedisCacheProvider
        {
            public static T GetValue<T>(string key)
            {
                try
                {
                    return Swj.Platform.Common.Cache.RedisCacheProvider.GetValue<T>(key);
                }
                catch (Exception ex)
                {
                    LogHelper.Error("Redis报错:" + ex.Message, ex);
                    return default(T);
                }
            }
            public static string GetValue(string key)
            {
                try
                {
                    return Swj.Platform.Common.Cache.RedisCacheProvider.GetValue(key);
                }
                catch (Exception ex)
                {
                    LogHelper.Error("Redis报错:" + ex.Message, ex);
                    return null;
                }
            }
            public static bool SetValue(string key, object obj, int timeOut = 60)
            {
                try
                {
                    return Swj.Platform.Common.Cache.RedisCacheProvider.SetValue(key, obj, timeOut);
                }
                catch (Exception ex)
                {
                    LogHelper.Error("Redis报错:" + ex.Message, ex);
                    return false;
                }
    
            }
            public static bool SetValue<T>(string key, T obj, int timeOut = 60)
            {
                try
                {
                    return Swj.Platform.Common.Cache.RedisCacheProvider.SetValue<T>(key, obj, timeOut);
                }
                catch (Exception ex)
                {
                    LogHelper.Error("Redis报错:" + ex.Message, ex);
                    return false;
                }
    
            }
            public static bool SetValue(string key, string v, int timeOut = 60)
            {
                try
                {
                    return Swj.Platform.Common.Cache.RedisCacheProvider.SetValue(key, v, timeOut);
                }
                catch (Exception ex)
                {
                    LogHelper.Error("Redis报错:" + ex.Message, ex);
                    return false;
                }
    
            }
            public static bool KeyExist(string key)
            {
                try
                {
                    return Swj.Platform.Common.Cache.RedisCacheProvider.KeyExist(key);
                }
                catch (Exception ex)
                {
                    LogHelper.Error("Redis报错:" + ex.Message, ex);
                    return false;
                }
            }
            public static bool RemoveValue(string key)
            {
                try
                {
                    return Swj.Platform.Common.Cache.RedisCacheProvider.RemoveValue(key);
                }
                catch (Exception ex)
                {
                    LogHelper.Error("Redis报错:" + ex.Message, ex);
                    return false;
                }
    
            }
        }
  • 相关阅读:
    luogu P2685 [USACO07OPEN]抓牛Catch That Cow
    codevs 2021 中庸之道
    1018. 锤子剪刀布 (20)
    1017. A除以B (20)
    1016. 部分A+B (15)
    1013. 数素数 (20)
    1011. A+B和C (15)
    《C语言程序设计(第四版)》阅读心得(三)
    《C语言程序设计(第四版)》阅读心得(二)
    1008. 数组元素循环右移问题 (20)
  • 原文地址:https://www.cnblogs.com/dj258/p/9253120.html
Copyright © 2011-2022 走看看