RedisRemoteEvictionExtension evicts key on SetAsync
See original GitHub issueHi,
Thanks for the great library.
Maybe I’m missing something but I have come across an issue that is confusing me:
Consider:
var layers = new ICacheLayer[]
{
new RedisCacheLayer(cacheLayerMultiplexer, databaseIndex: 1),
};
var myCacheStack = new CacheStack(
layers,
new ICacheExtension[]
{
new RedisRemoteEvictionExtension(
cacheLayerMultiplexer,
new ICacheLayer[]{})), // Do not evict any layers for this example
});
// Add something to cache stack
await myCacheStack.SetAsync("hello:world", 123, TimeSpan.FromMinutes(5));
// Check redis, no key found
var result = await myCacheStack.GetAsync<int>("hello:world");
if (result == null)
{
Console.WriteLine("No cache entry");
}
I wasn’t sure on the setup, originally I also had a MemoryCacheLayer as well, and I figured you would pass layersToEvict as:
layersToEvict = layers.Where(x => x.GetType() != typeof(RedisCacheLayer)).ToArray();
And pass this into the RedisRemoteEvictionExtension - however, whatever method I use to configure this extension, it seems to evict the key I add to redis, from redis, the moment its added.
Let me know if I have misunderstood something here! Thanks!
Issue Analytics
- State:
- Created 2 years ago
- Comments:18 (18 by maintainers)
Top Results From Across the Web
GetOrSetAsync fails to write value to redis when any ...
I'm trying a basic redis backed setup. SetAsync works, but GetOrSetAsync is not setting the value into redis. It is setting the value...
Read more >Key eviction
Overview of Redis key eviction policies (LRU, LFU, etc.) When Redis is used as a cache, it is often convenient to let it...
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
That would be perfect. This then enables any IoC container to be implemented in conjunction with this library. You managed to describe it a lot more succinctly than I did, I think I need another coffee in the morning before trying to outline an idea 😃
Forgot to close this one - with v0.12.0, there is now specific
ILocalCacheLayer
andIDistributedCacheLayer
interfaces and theRedisRemoteEvictionExtension
now asks theCacheStack
for the cache layers (rather than specifying them yourself), specifically looking forILocalCacheLayer
instances only. 🙂