private void StoreInCache(object result, InvocationContext invocationContext) { if (result != null && (!IsReturnTypeGenericCollection(result.GetType()) || ((IList)result).Count > 0)) { var cacheResturnobj = new CacheReturnModel(); cacheResturnobj.CacheEntry = result; try { var obj = (ICacheable)result; _memoryCacheService.Put(CacheKey, obj); } catch (Exception ex) { invocationContext.TempData = CreateCacheExceptionInfoMessage(CacheKey, ex); } } }
public static void StoreCacheObject(T data, IMemoryCacheService cacheObj, CacheConfig config, string cacheKey) { if (!config.Enabled) { return; } var dataToCache = new Cacheable <T> { TTL = DateTime.Now.AddMinutes(config.TimeToLiveMinutes), Model = data }; try { cacheObj.Remove(cacheKey); cacheObj.Put(cacheKey, dataToCache); } catch (Exception ex) { // LOG } }