StackRedis.L1
StackRedis.L1 copied to clipboard
Use L1 with ASP.NET Core distributed cache
I cannot get StrackRedis.L1
to work with ASP.NET Core distributed cache.
It's configured as following:
services.AddStackExchangeRedisCache(options =>
{
options.Configuration = distributedCacheConfig.ConnectionString;
options.ConnectionMultiplexerFactory = async () =>
{
var mux = await ConnectionMultiplexer.ConnectAsync(options.Configuration);
_ = new StackRedis.L1.RedisL1Database(mux.GetDatabase());
return mux;
};
});
When running the application the RedisL1Database
constructor gets called with no errors. However it does not seems like the in-memory cache layer is being used at all and Redis is instead being used as normal. Expecting the console to write mem cache hits. Also tired to set breakpoints inside L1 project with no hits.
I'm are running master of this project with Microsoft.Extensions.Caching.StackExchangeRedis/6.0.1 and StackExchange.Redis/2.2.4.
Should L1 work with ASP.NET Core distributed cache? Is there anything wrong in my configuration?
Hi @martingust - I'm afraid support for the ConnectionMultiplexer isn't there. .NET is calling the GetDatabase()
method itself - your RedisL1Database
instance isn't used.
To support it we'd have to create an implementation of IConnectionMultiplexer
where the GetDatabase()
returns RedisL1Database
instances.
Hi @martingust - I'm afraid support for the ConnectionMultiplexer isn't there. .NET is calling the
GetDatabase()
method itself - yourRedisL1Database
instance isn't used.To support it we'd have to create an implementation of
IConnectionMultiplexer
where theGetDatabase()
returnsRedisL1Database
instances.
Hey @johnnycardy! Ok, thanks for your reply! We will look into how we can them working together.