public void Set(HttpContext context, ApiCacheOutput response) { if (context.IsOutputCachingEnabled(out var options)) { var cacheMode = (CacheManager.Core.ExpirationMode)options.ExpirationMode; var cacheTimeout = TimeSpan.FromSeconds(options.ServerTimeSpan); string itemKey = _cacheKey.MakeCacheKey(context); _cacheManager.Add(new CacheItem <ApiCacheOutput>( itemKey, response, cacheMode, cacheTimeout)); if (!Keys.Contains(itemKey)) { Keys.Add(itemKey); } } }
public bool TryGetValue(HttpContext context, out ApiCacheOutput response) { response = _cacheManager.Get(_cacheKey.MakeCacheKey(context)) as ApiCacheOutput; return(response != null); }