using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Caching.Distributed; using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Volo.Abp.DependencyInjection; namespace Volo.Abp.Caching { [DisableConventionalRegistration] public class TestMemoryDistributedCache : MemoryDistributedCache, ICacheSupportsMultipleItems { public TestMemoryDistributedCache(IOptions optionsAccessor) : base(optionsAccessor) { } public TestMemoryDistributedCache(IOptions optionsAccessor, ILoggerFactory loggerFactory) : base(optionsAccessor, loggerFactory) { } public byte[][] GetMany(IEnumerable keys) { var values = new List(); foreach (var key in keys) { values.Add(Get(key)); } return values.ToArray(); } public async Task GetManyAsync(IEnumerable keys, CancellationToken token = default) { var values = new List(); foreach (var key in keys) { values.Add(await GetAsync(key, token)); } return values.ToArray(); } public void SetMany(IEnumerable> items, DistributedCacheEntryOptions options) { foreach (var item in items) { Set(item.Key, item.Value, options); } } public async Task SetManyAsync(IEnumerable> items, DistributedCacheEntryOptions options, CancellationToken token = default) { foreach (var item in items) { await SetAsync(item.Key, item.Value, options, token); } } public void RefreshMany(IEnumerable keys) { foreach (var key in keys) { Refresh(key); } } public async Task RefreshManyAsync(IEnumerable keys, CancellationToken token = default) { foreach (var key in keys) { await RefreshAsync(key, token); } } public void RemoveMany(IEnumerable keys) { foreach (var key in keys) { Remove(key); } } public async Task RemoveManyAsync(IEnumerable keys, CancellationToken token = default) { foreach (var key in keys) { await RemoveAsync(key, token); } } } }