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

StackExchange.Redis multiple Retries #231

Closed jcorrea-origin closed 6 years ago

jcorrea-origin commented 6 years ago

I have a problem when i try to do GetOrAdd method. Some times redis does not response, so RetryHelper execute a retry many times. I need to go to the database to after the first retry. Limit the number of retires and the time of timeout too.

retry1

retry2

i am using this configuration

retry3

and this is my function

public T GetData(Func dataLoadFunc, string region, object locker = null) { try { //return _cache.GetOrAdd(_key, region, (k, r) => InvokeAndSet(dataLoadFunc, r, locker)); var item = _cache.GetOrAdd(_key, region, (k, r) => new CacheItem(k,r, dataLoadFunc(), ExpirationMode.Absolute, _expiration)); return item.Value; } catch(Exception e) { return InvokeAndSet(dataLoadFunc, region); }

    }
MichaCo commented 6 years ago

I'm not getting what the issue is you are having. You configured it to retry 100 times. Change it to 1 maybe? ;) Retry timeouts and redis connection timeout can all be configured, too

jcorrea-origin commented 6 years ago

Thanks , i will try with that. And for some requets i will use Database.