Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use L1 with ASP.NET Core distributed cache #8

Open
martingust opened this issue Sep 9, 2022 · 2 comments
Open

Use L1 with ASP.NET Core distributed cache #8

martingust opened this issue Sep 9, 2022 · 2 comments

Comments

@martingust
Copy link

martingust commented Sep 9, 2022

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?

@martingust martingust changed the title Use L1 with Use L1 with ASP.NET Core distributed cache. Sep 9, 2022
@martingust martingust changed the title Use L1 with ASP.NET Core distributed cache. Use L1 with ASP.NET Core distributed cache Sep 9, 2022
@johnnycardy
Copy link
Owner

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.

@martingust
Copy link
Author

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.

Hey @johnnycardy! Ok, thanks for your reply! We will look into how we can them working together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants