Closed avireddy02 closed 6 years ago
In DI, CacheManager gets initialized the moment it is first used. This happens usually the first time it gets injected to a controller or something else. So, your website totally starts normally and hits the controller, but the constructor injection then fails with a connection exception... This means, your controller doesn't get initialized and the request will fail before it hits any controller method. Your app though is still running normally...
This should be fine for the most part as it will work normally again when the app can connect to Redis again.
If that behavior is not what you want, don't use ctor injection or Redis or build 2 controllers, one with and one without cache as fallback for example? Just ideas... there are many options, depends on what you need... ;)
thanks @MichaCo I actually found your blog which is very resourceful. WhatIfRedisStopsWorkingHowDoIkeepMyAppRunning
Using the above blog I have wrapped the CacheManagers Registration with try catch to solve DI issue when redis connectivity exceptions was thrown.
Suggestion: It would be great if this Link is explicitly specified on CacheManager Docs
Hey @avireddy02 great to hear you found that useful. The links is on of the first things on the http://cachemanager.michaco.net/ homepage though. I thought that's enough ;)
I'm using CacheManger with Redis Backplane and in-memory. Trying to build an application that should work even on redis/caching layer failures (may be degraded performance backed by sql db).
CacheManager is registered as part of Asp.Net Core DI. When ICacheManager is requested and redis connection throws exception then an my api is not even executing.
Referring AspnetCore.WebApp
When Redis connection fails ValuesController will never be invoked.
Is there a way to still use DI and get exception only on cacheManager crud operation? Open for suggestions