GetOrSetAsync fails to write value to redis when any redis extensions are enabled
See original GitHub issueI’m trying a basic redis backed setup. SetAsync works, but GetOrSetAsync is not setting the value into redis. It is setting the value into memory however, and does return the expected value.
If I remove the redis extensions, then it works and does set the value into redis. However I can’t really use redis without them, since I have scaled app services in azure. Note I need to remove both redis extensions, having either one will cause the problem.
Here’s a basic reproducer I mocked up in linqpad.
var redisConnection = ConnectionMultiplexer.Connect("-azure-cnxn-string-");
var c = new CacheStack(
new ICacheLayer[]
{
new MemoryCacheLayer(),
new RedisCacheLayer(redisConnection, 0)
},
new ICacheExtension[]
{
new AutoCleanupExtension(TimeSpan.FromMinutes(5)),
new RedisLockExtension(redisConnection, 0),
new RedisRemoteEvictionExtension(redisConnection)
});
// works
var result1 = c.SetAsync("setasync", "hello world", TimeSpan.FromHours(24)).GetAwaiter().GetResult();
// doesn't work
var result2 = c.GetOrSetAsync<string>("getorsetasync", old => Task.FromResult("hello world"), new CacheSettings(TimeSpan.FromMinutes(2))).GetAwaiter().GetResult();
result1.Dump();
result2.Dump();
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (4 by maintainers)
Top Results From Across the Web
It was not possible to connect to the redis server(s)
The error you are getting is usually a sign that you have not set abortConnect=false in your connection string. The default value for ......
Read more >Investigating timeout exceptions in StackExchange.Redis ...
StackExchange.Redis uses a configuration setting named “synctimeout” for synchronous operations, which is a default value for it is 1000 ms.
Read more >Diagnosing latency issues
When appendfsync is set to the value of everysec Redis performs a fsync every second. It uses a different thread, and if the...
Read more >Using StackExchangeRedis to integrate Redis with a C# .NET ...
Write data into Redis with StackExchangeRedis ... We should keep in mind that StackExchangeRedis is not a Redis client for C# .NET. Instead,...
Read more >Redis Extension Reference Guide
The Quarkus Redis extension allows integrating Quarkus applications with Redis. ... You can use the setnx method only to set the value if...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
(Still me) Maybe allow the user to register the layers they want evicted with the remote extension when constructed. That way the extension doesn’t need to worry about the logic and what a user considers a distributed cache layer vs local. Also gives different apps which may share the cache a bit more flexibility.
I’ve released 0.7.0 with the Redis fixes. Thanks again for raising the issues, if you encounter any others, let me know!