aspnetcore: Items with configured expiration stored in IDistributedCache (using RedisCache) end up non-expiring in Redis
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
When I store items using e.g.
// ...
services.AddStackExchangeRedisCache(_ => { })
// ...
IDistributedCache cache = // from DI
cache.SetAsync(
"key",
"Test"u8.ToArray(),
new() { AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(10) })
the key ends up as non-expiring in Redis.
Expected Behavior
Keys should be set to expire in Redis if configured accordingly.
Steps To Reproduce
Unfortunately I can only reproduce this in a very specific environment:
- client with Microsoft.Extensions.Caching.StackExchangeRedis @ 9.0.0 (SE.Redis @ 2.7.27 or 2.8.22) on Suse CloudFoundry
- Bitnami Redis v7.0.4 (yes, outdated)
Connecting to the same cluster from my development environment (Ubuntu) or downgrading Microsoft.Extensions.Caching.StackExchangeRedis @ 8.0.11 does not trigger the bug (regardless of the SE.Redis version).
Exceptions (if any)
No response
.NET Version
SDK 9.0.100, targeting net9.0
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 31 (19 by maintainers)
On an internal chat, @philon-msft echoed the sentiment that the addresses returned from
CLUSTER NODESshould be routable by the client. If they’re not, that would 100% explain these symptoms because:CLUSTER NODESwill add some IP-based endpoints, but they will all fail to connect-MOVEDthat seems to include the host on redis 7-MOVED, adding extra endpoints as neededSo; long term, we can see whether SE.Redis should improve support for host-based
CLUSTERrouting, but right now, the short version would be: make theCLUSTER NODESadvertised endpoints routable.@CaringDev thoughts?
@CaringDev if I can refer you to
CLUSTER NODES, emphasis mine:It seems fairly explicit that the IP endpoint is the correct case, and that the text name (which is configurable) is intended for reference only. This is similarly the case in
CLUSTER SHARDS, which has a different layout but again specifies that the IP and port is the expected use-case, and that the hostname is optional and may or may not be included.The other thing we could do is that code is: in
EXPIRE, check(bool)resp- it should betrue:and output
serverSaidNoat the end; we hope it is0, but it’ll be interesting to see if it is non-zero(being able to replay and analyze traffic snapshots like this is super useful)
To be clear: what I did here was
EXPIREentryEXPIRE, which in my editor automatically shows other occurrencesHMSETshortly before theEXPIRE