コード例 #1
0
        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;
        }
コード例 #2
0
        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;
        }