public void Refresh_Should_Succeed() { var cacheKey = Guid.NewGuid().ToString(); var cacheValue = "value"; _provider.Set(cacheKey, cacheValue, _defaultTs); var tmp = _provider.Get <string>(cacheKey); Assert.Equal("value", tmp.Value); var newValue = "NewValue"; _provider.Refresh(cacheKey, newValue, _defaultTs); var act = _provider.Get <string>(cacheKey); Assert.Equal("NewValue", act.Value); }
/// <summary> /// Subscribes the handle. /// </summary> /// <param name="channel">Channel.</param> /// <param name="value">Value.</param> private void SubscribeHandle(RedisChannel channel, RedisValue value) { var message = _serializer.Deserialize <EasyCachingMessage>(value); switch (message.NotifyType) { case NotifyType.Add: _localCachingProvider.Set(message.CacheKey, message.CacheValue, message.Expiration); break; case NotifyType.Update: _localCachingProvider.Refresh(message.CacheKey, message.CacheValue, message.Expiration); break; case NotifyType.Delete: _localCachingProvider.Remove(message.CacheKey); break; } }
/// <summary> /// Consumers the received. /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">E.</param> private void OnConsumerReceived(object sender, BasicDeliverEventArgs e) { var message = _serializer.Deserialize <EasyCachingMessage>(e.Body); switch (message.NotifyType) { case NotifyType.Add: _localCachingProvider.Set(message.CacheKey, message.CacheValue, message.Expiration); break; case NotifyType.Update: _localCachingProvider.Refresh(message.CacheKey, message.CacheValue, message.Expiration); break; case NotifyType.Delete: _localCachingProvider.Remove(message.CacheKey); break; } }