예제 #1
0
        public T GetCached <T>(string cacheName, Func <T> setterResponse, DateTime cacheUntil)
            where T : class
        {
            var cachedItem = GetCached <T>(cacheName);

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

            var uncachedResult = setterResponse();

            if (IsCacheEnabled())
            {
                MemoryCacheManager.SetItem(cacheName, uncachedResult, cacheUntil);
            }

            return(uncachedResult);
        }
예제 #2
0
 public T GetCached <T>(string cacheName)
     where T : class
 {
     return(IsCacheEnabled() ? MemoryCacheManager.GetItem <T>(cacheName) : null);
 }