c#-4.0 - SETEX 中的过期时间无效,sPort : 12702 in Redis

标签 c#-4.0 redis

我在使用 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/

相关文章:

c# - 在不指定列的情况下显示数据库中的数据

visual-studio-2010 - 错误 : Index was outside the bounds of the array in Petapoco with Visual Studio 2010

linq - GroupBy 使用 LINQ 但基于另一列的不同,并且仍然能够计算其他记录

Go lang Redis PubSub 在不同的 go 路由中用于发布和订阅

c#-4.0 - 编写要在 Web API MessageHandler 中使用的解压缩机制

asp.net - EPiServer 与带有页面类型生成器的 EPiServer

asp.net - Azure Redis 缓存自动清除 PubSub channel

javascript - Node.js 中是否可以嵌套 Redis 语句?

php - 如何用 Golang 解码 PHP 序列化的 Redis 响应

node.js - 如何为授权用户验证每个 API?