Comments (4)
What do you exactly mean with "support generic instance"?
If you don't want to configure each type, use "object". there are overloads everywhere to create non typed instances...
If you want to use DI to inject an instance per type, see #20
Cachemanager actually handles retries for you if you use Redis. you can controll the connection timeout in the redis configuration and the cache manager itself has properties for retry timeout and max retries.
That being said, do you have a reproduceable configuration/scenario you are using where this is not working? Please post it here so that I can test it.
Thanks
from cachemanager.
I'm use autofac,but I don't know how to register an instance in bulk,Can you provide an example for me,thank you !
Here is my code:
//var intCache = CacheFactory.FromConfiguration("intCache", cfg);
//var stringCache = CacheFactory.FromConfiguration("stringCache", cfg);
//var objectCache = CacheFactory.FromConfiguration("objectCache", cfg);
//builder.RegisterInstance(intCache);
//builder.RegisterInstance(stringCache);
//builder.RegisterInstance(objectCache);
//builder.RegisterInstance(cache);
var container = builder.Build();
DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
from cachemanager.
Well, autofac also has a way to register open generics, something like this should work:
var cacheConfig = ConfigurationBuilder.BuildConfiguration(...);
var builder = new ContainerBuilder();
builder
.RegisterGeneric(typeof(BaseCacheManager<>))
.WithParameters(new[]
{
new TypedParameter(typeof(string), "myCache"),
new TypedParameter(typeof(CacheManagerConfiguration), cacheConfig)
})
.As(typeof(ICacheManager<>))
.SingleInstance();
Don't forget the SingleInstance()
call to make each cache manager instance the container creates, a singleton.
from cachemanager.
In version 0.9.3 should be:
builder.RegisterGeneric(typeof(BaseCacheManager<>))
.WithParameters(new[]
{
new TypedParameter(typeof(ICacheManagerConfiguration), cacheConfig)
})
.As(typeof(ICacheManager<>))
.SingleInstance();
from cachemanager.
Related Issues (20)
- Json serializer does not support on redis? HOT 1
- Is it possible to do cache eviction when backplane is down HOT 1
- Cache manager locking threads HOT 2
- .Get() after .Add() or .AddOrUpdate fetches from Redis unexpectedly when using inProcessCache HOT 2
- Supporting .NET Standard 2.1 HOT 1
- Is CacheManager a dead project? HOT 1
- CacheManager.StackExchange.Redis add list type data problem
- How to get all the following data according to the prefix of the key
- Ocelot Cache - How do we Cache only success(200) response from micro services via API Gateway HOT 1
- Is there a plan to release a stable 2.x version ? HOT 1
- [Question] Using redis both for cache and for signalR HOT 1
- Changes in the object reflect in Cache without updating HOT 2
- Not possible to flush whole cache when using in-memory and redis handles HOT 2
- How to run AspnetCore.WebApp for NET 5.0? HOT 1
- Can we override config expiration settings during Add()? HOT 2
- Is this project still supported? HOT 3
- How to use SQL Server? HOT 1
- [Question] synchronize cache layer on application startup HOT 1
- New version / Nuget packages HOT 8
- How to 'add' item to all layers very first time HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cachemanager.