RedisDependencyManager doesn't handle redis not being available

Issue #47 closed
Paul Donovan created an issue

Using version 4.1.1 ,if the redis server isn't running or can't be connected to, the call to _redisDatabase.KeyExists() in RegisterParentDependencyDefinition() throws an exception.

My config is as follows: <add key="Cache.CacheToUse" value="redis" /> <add key="Cache.IsCacheEnabled" value="true" /> <add key="Cache.IsCacheDependencyManagementEnabled" value="true" /> <add key="Cache.DependencyManagerToUse" value="default"/> <add key="Cache.DistributedCacheServers" value="localhost:6379"/> <add key="Cache.CacheSpecificData" value="" />

It looks like the method: Get<T>(string cacheKey, DateTime absoluteExpiryDate, Func<T> getData, string parentKey = null, CacheDependencyAction actionForDependency = CacheDependencyAction.ClearDependentItems) handles the cache not being available when checking for the item, it's the code that tries to update the dependencies that doesn't.

Comments (7)

  1. Paul Donovan reporter

    After playing with this some more, I think there are two situations to consider:

    1. redis is not available when the application starts (or is recycled)
    2. redis is temporarily unavailable while the application is running

    Event 2 is more likely to occur and I don't want it to make my app throw an exception. When reading, it should treat it as if it's not cached. An error when writing is trickier - perhaps only this web app can't connect, and others are fine? What if this is a dependency clear - other apps may still be able to get old data from redis.

  2. Paul Glavich repo owner

    Hi Paul,

    Thanks for reporting this and yes, there needs to be more error handling around dependency management. Obviously in the interim you can disable dependency management via config but I will endeavor to create more robust handling of errors in the dependency management area.

  3. Paul Glavich repo owner

    Just a note that this repository has moved to github now. See here for new repo. All issues will be slowly migrated as well. If you still find this issue important, please provide your Github account so I can recreate this issue and link it to your Github account, otherwise I will simply close the issue.

  4. Log in to comment