MichaCo / CacheManager

CacheManager is an open source caching abstraction layer for .NET written in C#. It supports various cache providers and implements many advanced features.
http://cachemanager.michaco.net
Apache License 2.0
2.34k stars 457 forks source link

Is there a way not keep redis connection in app.config? #263

Closed macchmie3 closed 5 years ago

macchmie3 commented 5 years ago

Hi, Im currently configuring cache as follows:

var cache= CacheFactory.Build(settings => { settings.WithJsonSerializer() .WithSystemRuntimeCacheHandle("InProcessCache") .And .WithRedisBackplane("RedisConnection") .WithRedisCacheHandle("RedisConnection") .WithExpiration(ExpirationMode.Sliding, TimeSpan.FromMinutes(15)); });

Is there a way to not use names of app.config connection strings like "RedisConnection" in this example, but to use directly a connection string like "localhost:6379,ssl=false,allowAdmin=true,syncTimeout=3000"? This is troubling me as I would like to retieve the connectionstring from a safe keyvault storage, and not store the connection in app.config.

MichaCo commented 5 years ago

Yes, you can just "reference" a connection string by name

var cache = CacheFactory.Build(c => c.WithRedisCacheHandle("fromConnectionStrings"));

And CacheManager should load that from your app.config.

macchmie3 commented 5 years ago

Yes I understand - the thing is I do not want to reference connection string, but use it directly - like

var cache = CacheFactory.Build(c => c.WithRedisCacheHandle("localhost:6379,ssl=false,allowAdmin=true,syncTimeout=3000"));

MichaCo commented 5 years ago

That's where you use the normal .WithRedisConfiguration("key", "connectionstring") method to configure Redis...