Ejemplo n.º 1
0
        /// <summary>
        /// Overload for the <see cref="ContentCacheManager.Resolve"/> method returning the most
        /// optimized result based on the MimeType and CompressionType from the IRequestContext.
        /// <param name="expireCacheIn">How long to cache for, null is no expiration</param>
        /// </summary>
        public static object ToOptimizedResultUsingCache <T>(
            this IRequest requestContext, ICacheClient cacheClient, string cacheKey,
            TimeSpan?expireCacheIn, Func <T> factoryFn)
        {
            var cacheResult = cacheClient.ResolveFromCache(cacheKey, requestContext);

            if (cacheResult != null)
            {
                return(cacheResult);
            }

            cacheResult = cacheClient.Cache(cacheKey, factoryFn(), requestContext, expireCacheIn);
            return(cacheResult);
        }