C# Redis 过期机制不生效问题

引用: https://ask.csdn.net/questions/358802 根据这里的代码写出监听事件后,事件并没有生效

在比对了多次配置文件后,终于发现了一点蹊跷,在配置中不能有与之相冲的配置,于是处理方法就很简单了。

将无关监听事件注释,再把自己需要的取消注释,即可让监听事件生效

复制代码
#  The "notify-keyspace-events" takes as argument a string that is composed
#  of zero or multiple characters. The empty string means that notifications
#  are disabled.
#
#  Example: to enable list and generic events, from the point of view of the
#           event name, use:
#
#  notify-keyspace-events Elg #被注释的代码
#
#  Example 2: to get the stream of the expired keys subscribing to channel
#             name __keyevent@0__:expired use:
#
#被取消注释的代码 notify-keyspace-events Ex  
复制代码

保存配置后,重启Redis服务即可让过期键监听事件生效。

posted @   全面回憶  阅读(1728)  评论(0编辑  收藏  举报
编辑推荐:
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
阅读排行:
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 没有源码,如何修改代码逻辑?
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
点击右上角即可分享
微信分享提示