/// <summary> /// Remove the specified cacheKey. /// </summary> /// <param name="cacheKey">Cache key.</param> public void Remove(string cacheKey) { ArgumentCheck.NotNullOrWhiteSpace(cacheKey, nameof(cacheKey)); //distributed cache at first _distributedCache.Remove(cacheKey); _localCache.Remove(cacheKey); //send message to bus _bus.Publish(_options.TopicName, new EasyCachingMessage { Id = _cacheId, CacheKeys = new string[] { cacheKey } }); }
public void Send_Msg_Throw_Exception_Should_Not_Break() { A.CallTo(() => fakeBus.Publish("test_topic", A <EasyCachingMessage> ._)).Throws((arg) => new Exception()); fakeHybrid.Remove("fake-remove"); Assert.True(true); }
/// <summary> /// Remove the specified cacheKey. /// </summary> /// <param name="cacheKey">Cache key.</param> public void Remove(string cacheKey) { ArgumentCheck.NotNullOrWhiteSpace(cacheKey, nameof(cacheKey)); try { // distributed cache at first _distributedCache.Remove(cacheKey); } catch (Exception ex) { LogMessage($"remove cache key [{cacheKey}] error", ex); } _localCache.Remove(cacheKey); // send message to bus _busSyncWrap.Execute(() => _bus.Publish(_options.TopicName, new EasyCachingMessage { Id = _cacheId, CacheKeys = new string[] { cacheKey } })); }