private static void ProceedResult <T>(ICacheProvider cache, string key, CachedResultLock cachedResultLock, CachableResult <T> cachableResult) { object result = null; if (cachableResult != null) { // if cachableResult.Result is null, it's still a result. So we need to cache it as EmptyResult object // so the next time we didn't get null from cache and had to go create result // once again. But we can do it only if dependency keys are null/empty, or they don't include // cachableResult data, because otherwise will be caching EmptyResult object // with dependeny key calculated for null object which is incorrect behavior. result = cachableResult.Result; if (result == null) { result = EmptyResult; } cache.Add(key, result, cachableResult.Parameters); } cachedResultLock.Result = result; cachedResultLock.IsExecuted = true; }
private static void ReleaseCachedResultLock(string key, CachedResultLock cachedResultLock) { cachedResultLock.Mutex.Release(); CachedResultLock tmp; Locks.TryRemove(key, out tmp); }
private static void ProceedExceptionResult(CachedResultLock cachedResultLock, Exception exception) { var result = new ExceptionResult { Exception = exception }; cachedResultLock.Result = result; cachedResultLock.IsExecuted = true; }
private static void ProceedResult <T> (ICacheProvider cache, string key, CachedResultLock cachedResultLock, [CanBeNull] CachableResult <T> cachableResult) { object result = null; if (cachableResult != null) { // if cachableResult.Result is null, it's still a result. So we need to cache it as EmptyResult object // so the next time we didn't get null from cache and had to go create result once again. result = cachableResult.Result; if (result == null) { result = EmptyResult; } cache.Add(key, result, cachableResult.Parameters); } cachedResultLock.Result = result; cachedResultLock.IsExecuted = true; }