I have an application which is getting lots of Redis timeout errors thrown.
The way I'm configuring the cache in the Startup.cs is like this:
var redis = ConnectionMultiplexer.Connect(Configuration.GetValue<string>("RedisConnection"));
services.AddDataProtection(
options => { options.ApplicationDiscriminator = "my-ap";}
).PersistKeysToRedis(redis, "my-ap-data-protection-keys");
services.AddDistributedRedisCache(options =>
{
options.Configuration = Configuration.GetValue<string>("RedisConnection");
});
I'm going through this document here which mentions the best practice of using Redis is like this:
private static Lazy<ConnectionMultiplexer> lazyConnection = new Lazy<ConnectionMultiplexer>(() => {
return ConnectionMultiplexer.Connect("RedisConnection"); });
public static ConnectionMultiplexer Connection { get { return lazyConnection.Value; } }
Part 1 of the question: It's not really clear to me how I can incorporate this into my code for the distribution keys. Do I just add a static method in my startup class?
Part 2 of the question: I am using the AddDistributedRedisCache extension method from Microsoft.Extensions.Caching.Redis Version 2.1.2.0 and I can't find the area where the recommended method above is being used