zoukankan      html  css  js  c++  java
  • ServiceStack.Redis 缓存过期,并未失效的暂时解决办法

    服务器:Redis版本运行环境如图,生产环境是全内存运行。

    客户端NuGet 引入:ServiceStack.Redis

    加入缓存代码:

            /// <summary>
            ///  Set
            /// </summary>
            /// <typeparam name="T">类型</typeparam>
            /// <param name="key">键</param>
            /// <param name="t">值</param>
            /// <param name="timeout">多少分钟后过期</param>
            /// <returns></returns>
            public static bool Set<T>(string key, T t, double minOut = 60*3)
            {
                using (var redisClient = RedisManager.GetClient())
                {
                    key = "Str_" + key;
                    return redisClient.Set<T>(key, t, ExpireDateTime(minOut));
                }
            }
    

    但过了相应的时间之后,缓存没有失效。做了各种尝试.... 最后:

     获取所有缓存名称

    List<string> GetAllKeys();
    

     定点清除,也可以全部干掉

            void FlushAll();
            T Get<T>(string key);
            IDictionary<string, T> GetAll<T>(IEnumerable<string> keys);
            long Increment(string key, uint amount);
            bool Remove(string key);
            void RemoveAll(IEnumerable<string> keys);
    

    希望给一些方法。解决问题不全都靠技术,方法也行。 

  • 相关阅读:
    topK问题 前K个高频元素 leetcode692
    反转链表 leetcode206
    关于IO多路复用的简单整理
    两数之和 leetcode1
    使用 jenkins 发布 前端 项目
    CentOS7 部署 nacos 集群
    JWT
    keepalived 的 unicast 单播模式
    使用 keepalived 高可用 nginx
    翻转二叉树 leetcode226
  • 原文地址:https://www.cnblogs.com/recordman/p/4568285.html
Copyright © 2011-2022 走看看