question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GetOrSetAsync fails to write value to redis when any redis extensions are enabled

See original GitHub issue

I’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:closed
  • Created 3 years ago
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
epilsitscommented, Nov 4, 2020

(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.

0reactions
Turnerjcommented, Nov 17, 2020

I’ve released 0.7.0 with the Redis fixes. Thanks again for raising the issues, if you encounter any others, let me know!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found