public void ExpiredGlobalRegionTokenRemovesAll() { //Arrange var cache = GetPlatformMemoryCache(); var key1 = "myKey1"; var key2 = "myKey2"; var value1 = new object(); var value2 = new object(); var token1 = CacheRegion.CreateChangeTokenForKey(key1); var token2 = CacheRegion2.CreateChangeTokenForKey(key2); cache.Set(key1, value1, token1); cache.Set(key2, value2, token2); //Act GlobalCacheRegion.ExpireRegion(); //Assertion var result = cache.Get(key1); Assert.Null(result); result = cache.Get(key2); Assert.Null(result); }
protected virtual void OnConnectionRestored(object sender, ConnectionFailedEventArgs e) { // Return cache to the same state as it was initially. // Don't set directly true because it may be disabled in app settings CacheEnabled = _storefrontOptions.CacheEnabled; // We should fully clear cache because we don't know // what's changed in another instances since Redis became unavailable GlobalCacheRegion.ExpireRegion(); }
protected virtual void OnConnectionFailed(object sender, ConnectionFailedEventArgs e) { // If we have no connection to Redis, we can't invalidate cache on another platform instances, // so the better idea is to disable cache at all for data consistence CacheEnabled = false; // We should fully clear cache because we don't know // what's changed until platform found Redis is unavailable GlobalCacheRegion.ExpireRegion(); }
protected virtual void OnConnectionFailed(object sender, ConnectionFailedEventArgs e) { _log.LogError($"Redis disconnected from instance { _instanceId }. Endpoint is {e.EndPoint}, failure type is {e.FailureType}"); // If we have no connection to Redis, we can't invalidate cache on another platform instances, // so the better idea is to disable cache at all for data consistence CacheEnabled = false; // We should fully clear cache because we don't know // what's changed until platform found Redis is unavailable GlobalCacheRegion.ExpireRegion(); }
public void Global_Cache_Region_Expired_Successfully() { var platformMemoryCache = GetPlatformMemoryCache(); var firstValue = GetSampleValueWithCache(platformMemoryCache); var secondValue = GetSampleValueWithCache(platformMemoryCache); GlobalCacheRegion.ExpireRegion(); var thirdValue = GetSampleValueWithCache(platformMemoryCache); Assert.Equal(firstValue, secondValue); Assert.NotEqual(firstValue, thirdValue); }
protected virtual void OnConnectionRestored(object sender, ConnectionFailedEventArgs e) { _log.LogInformation($"Redis connection restored for instance { ServerId }"); _telemetryClient.TrackEvent("RedisConnectionRestored", new Dictionary <string, string> { { "channelName", _redisCachingOptions.ChannelName }, { "cacheId", ServerId } }); // Return cache to the same state as it was initially. // Don't set directly true because it may be disabled in app settings CacheEnabled = _cachingOptions.CacheEnabled; // We should fully clear cache because we don't know // what's changed in another instances since Redis became unavailable GlobalCacheRegion.ExpireRegion(); }
protected virtual void OnConnectionFailed(object sender, ConnectionFailedEventArgs e) { _log.LogError($"Redis disconnected from instance { ServerId }. Endpoint is {e.EndPoint}, failure type is {e.FailureType}"); _telemetryClient.TrackException(e.Exception); _telemetryClient.TrackEvent("RedisDisconnected", new Dictionary <string, string> { { "channelName", _redisCachingOptions.ChannelName }, { "cacheId", ServerId }, { "endpoint", e.EndPoint.ToString() }, { "failureType", e.FailureType.ToString() } }); // If we have no connection to Redis, we can't invalidate cache on another platform instances, // so the better idea is to disable cache at all for data consistence CacheEnabled = false; // We should fully clear cache because we don't know // what's changed until platform found Redis is unavailable GlobalCacheRegion.ExpireRegion(); }
public ActionResult ResetCache() { GlobalCacheRegion.ExpireRegion(); return(StoreFrontRedirect("~/")); }
public ActionResult ResetPlatformCache() { GlobalCacheRegion.ExpireRegion(); return(NoContent()); }