我在使用 Redis 缓存时间=0 时遇到错误。同时使用Redis缓存时间=1,它按预期工作。
如何设置Redis缓存时间值为0,请帮忙
错误消息
"Message":"An error has occurred.","ExceptionMessage":"invalid expire time in SETEX, sPort: 12702, LastCommand: ","ExceptionType":"ServiceStack.Redis.RedisResponseException"
我想将过期时间设置为 0,为什么是因为我使用的是动态页面并且它有很多 block 。来自配置文件的 Redis 缓存时间。示例: block 1,redis 缓存时间为 2 分钟。特别是当我不需要redis缓存时,我会在配置文件中将0更改为redis缓存时间。
最佳答案
In particular time i dont want redis cache, that time i go and change 0 as redis cache time in configuration file.
看来你不想通过命令redis存储key来存储key。这是非常不方便的。
如果您不想更改应用程序代码,则只需将其保存 1 秒,这是最短的时间。正如 setex
命令所期望的,时间是正,意味着大于零。
否则,您可以通过在 ttl 为零时忽略存储在缓存中来调整代码。或者您可以使用 psetex 将其保存在 redis 中 1 毫秒替换了setex。
关于c#-4.0 - SETEX 中的过期时间无效,sPort : 12702 in Redis,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49529882/