/// <summary> /// Tries to get a previously cached response for the specified invocation, returning false if not found. /// </summary> /// <param name="invocation"></param> /// <param name="cacheClient"></param> /// <param name="cacheKey"></param> /// <param name="region"></param> /// <returns></returns> private static bool GetCachedResponse(IInvocation invocation, ICacheClient cacheClient, string cacheKey, string region) { if (cacheKey == null || !cacheClient.RegionExists(region)) { return(false); } // check cache var response = cacheClient.Get(cacheKey, new CacheGetOptions(region)); if (response != null) { invocation.ReturnValue = response; return(true); } return(false); }
/// <summary> /// Tries to get a previously cached response for the specified invocation, returning false if not found. /// </summary> /// <param name="invocation"></param> /// <param name="request"> </param> /// <param name="cacheClient"></param> /// <param name="region"></param> /// <returns></returns> private static bool GetCachedResponse(IInvocation invocation, object request, ICacheClient cacheClient, string region) { if (!cacheClient.RegionExists(region)) { return(false); } var strategy = ResponseDataCachingStrategy.Get(invocation.Method); var cacheKeys = strategy.GetCacheKeys(request); if (cacheKeys == null || cacheKeys.Length == 0) { return(false); } var cacheData = new Dictionary <string, object>(); foreach (var cacheKey in cacheKeys) { var data = cacheClient.Get(cacheKey, new CacheGetOptions(region)); if (data != null) //Assume null is not a relevant cache entry. { cacheData[cacheKey] = data; } } if (cacheData.Count > 0) { var response = strategy.ConstructResponse(request, cacheData); if (response != null) { invocation.ReturnValue = response; return(true); } } return(false); }
public bool RegionExists(string region) { return(_cacheClient.RegionExists(region)); }
/// <summary> /// Tries to get a previously cached response for the specified invocation, returning false if not found. /// </summary> /// <param name="invocation"></param> /// <param name="cacheClient"></param> /// <param name="cacheKey"></param> /// <param name="region"></param> /// <returns></returns> private static bool GetCachedResponse(IInvocation invocation, ICacheClient cacheClient, string cacheKey, string region) { if (cacheKey == null || !cacheClient.RegionExists(region)) return false; // check cache var response = cacheClient.Get(cacheKey, new CacheGetOptions(region)); if (response != null) { invocation.ReturnValue = response; return true; } return false; }
/// <summary> /// Tries to get a previously cached response for the specified invocation, returning false if not found. /// </summary> /// <param name="invocation"></param> /// <param name="request"> </param> /// <param name="cacheClient"></param> /// <param name="region"></param> /// <returns></returns> private static bool GetCachedResponse(IInvocation invocation, object request, ICacheClient cacheClient, string region) { if (!cacheClient.RegionExists(region)) return false; var strategy = ResponseDataCachingStrategy.Get(invocation.Method); var cacheKeys = strategy.GetCacheKeys(request); if (cacheKeys == null || cacheKeys.Length == 0) return false; var cacheData = new Dictionary<string, object>(); foreach (var cacheKey in cacheKeys) { var data = cacheClient.Get(cacheKey, new CacheGetOptions(region)); if (data != null) //Assume null is not a relevant cache entry. cacheData[cacheKey] = data; } if (cacheData.Count > 0) { var response = strategy.ConstructResponse(request, cacheData); if (response != null) { invocation.ReturnValue = response; return true; } } return false; }