/// <summary> /// Removes all. /// </summary> /// <param name="cacheKeys">Cache keys.</param> public void RemoveAll(IEnumerable <string> cacheKeys) { ArgumentCheck.NotNullAndCountGTZero(cacheKeys, nameof(cacheKeys)); _localCache.RemoveAll(cacheKeys); _distributedCache.RemoveAllAsync(cacheKeys); //send message to bus in order to notify other clients. _bus.Publish(_options.TopicName, new EasyCachingMessage { Id = _cacheId, CacheKeys = cacheKeys.ToArray() }); }
/// <summary> /// Removes all. /// </summary> /// <param name="cacheKeys">Cache keys.</param> public void RemoveAll(IEnumerable <string> cacheKeys) { ArgumentCheck.NotNullAndCountGTZero(cacheKeys, nameof(cacheKeys)); try { _distributedCache.RemoveAllAsync(cacheKeys); } catch (Exception ex) { LogMessage($"remove all from distributed provider error [{string.Join(",", cacheKeys)}]", ex); } _localCache.RemoveAll(cacheKeys); // send message to bus in order to notify other clients. _busSyncWrap.Execute(() => _bus.Publish(_options.TopicName, new EasyCachingMessage { Id = _cacheId, CacheKeys = cacheKeys.ToArray() })); }
public override async Task <bool> RemoveMany(IEnumerable <string> ordersInvolved) { try { await _cachingProvider.RemoveAllAsync(ordersInvolved); return(true); } catch (Exception e) { return(false); } }
/// <summary> /// Removes all async. /// </summary> /// <returns>The all async.</returns> /// <param name="cacheKeys">Cache keys.</param> public async Task RemoveAllAsync(IEnumerable <string> cacheKeys) { ArgumentCheck.NotNullAndCountGTZero(cacheKeys, nameof(cacheKeys)); await _localCachingProvider.RemoveAllAsync(cacheKeys); try { await _distributedCachingProvider.RemoveAllAsync(cacheKeys); } catch (Exception ex) { System.Console.WriteLine(ex.Message); } }
protected virtual async Task RemoveAllAsync_Should_Succeed() { var dict = GetMultiDict("removeallasync:"); _provider.SetAll(dict, _defaultTs); await _provider.RemoveAllAsync(new List <string> { "removeallasync:key:1", "removeallasync:key:2" }); var res1 = _provider.Get <string>("removeallasync:key:1"); var res2 = _provider.Get <string>("removeallasync:key:2"); Assert.False(res1.HasValue); Assert.False(res2.HasValue); }
/// <summary> /// Removes all async. /// </summary> /// <returns>The all async.</returns> /// <param name="cacheKeys">Cache keys.</param> public async Task RemoveAllAsync(IEnumerable <string> cacheKeys) { ArgumentCheck.NotNullAndCountGTZero(cacheKeys, nameof(cacheKeys)); try { await _distributedCache.RemoveAllAsync(cacheKeys); } catch (Exception ex) { _logger?.LogError(ex, "remove all async from distributed provider error [{0}]", string.Join(",", cacheKeys)); } await _localCache.RemoveAllAsync(cacheKeys); // send message to bus in order to notify other clients. await _bus.PublishAsync(_options.TopicName, new EasyCachingMessage { Id = _cacheId, CacheKeys = cacheKeys.ToArray() }); }
/// <summary> /// Removes all. /// </summary> /// <param name="cacheKeys">Cache keys.</param> /// <param name="cancellationToken">cancellationToken</param> /// <returns>Task</returns> public Task RemoveAllAsync(IEnumerable <string> cacheKeys, CancellationToken cancellationToken = default) { return(_easyCachingProvider.RemoveAllAsync(cacheKeys)); }