private static TResult GetCachedOrDefault <TResult>(string cacheKey, IDataCacheStore cache, TResult defaultResult) { object item; if (cache.TryGetValue(cacheKey, out item)) { if (item is TResult result) { return(result); } } return(defaultResult); }
private bool ResourceIsDisabled(string resourceKey, out bool manuallyDisabled) { object countObj; if (_failCountCache.TryGetValue(resourceKey, out countObj)) { if (countObj is int) { manuallyDisabled = (int)countObj >= 2 * failCountLimit; return((int)countObj >= failCountLimit); } } manuallyDisabled = false; return(false); }