/// <summary> /// Removes the specified cacheKey async. /// </summary> /// <returns>The async.</returns> /// <param name="cacheKey">Cache key.</param> public async Task RemoveAsync(string cacheKey) { ArgumentCheck.NotNullOrWhiteSpace(cacheKey, nameof(cacheKey)); //distributed cache at first await _distributedCache.RemoveAsync(cacheKey); await _localCache.RemoveAsync(cacheKey); //send message to bus await _bus.PublishAsync(_options.TopicName, new EasyCachingMessage { Id = _cacheId, CacheKeys = new string[] { cacheKey } }); }
public async Task Send_Msg_Async_Throw_Exception_Should_Not_Break() { CancellationToken token = new CancellationToken(); A.CallTo(() => fakeBus.PublishAsync("test_topic", A <EasyCachingMessage> ._, token)).ThrowsAsync((arg) => new Exception()); await fakeHybrid.RemoveAsync("fake-remove"); Assert.True(true); }
/// <summary> /// Removes the specified cacheKey async. /// </summary> /// <returns>The async.</returns> /// <param name="cacheKey">Cache key.</param> public async Task RemoveAsync(string cacheKey) { ArgumentCheck.NotNullOrWhiteSpace(cacheKey, nameof(cacheKey)); try { // distributed cache at first await _distributedCache.RemoveAsync(cacheKey); } catch (Exception ex) { _logger?.LogError(ex, "remove cache key [{0}] error", cacheKey); } await _localCache.RemoveAsync(cacheKey); // send message to bus await _bus.PublishAsync(_options.TopicName, new EasyCachingMessage { Id = _cacheId, CacheKeys = new string[] { cacheKey } }); }