|
|
|
@ -21,26 +21,115 @@ namespace Volo.Abp.Caching; |
|
|
|
/// </summary>
|
|
|
|
/// <typeparam name="TCacheItem">The type of cache item being cached.</typeparam>
|
|
|
|
public class DistributedCache<TCacheItem> : |
|
|
|
DistributedCache<TCacheItem, string>, |
|
|
|
IDistributedCache<TCacheItem> |
|
|
|
where TCacheItem : class |
|
|
|
{ |
|
|
|
public DistributedCache( |
|
|
|
IOptions<AbpDistributedCacheOptions> distributedCacheOption, |
|
|
|
IDistributedCache cache, |
|
|
|
ICancellationTokenProvider cancellationTokenProvider, |
|
|
|
IDistributedCacheSerializer serializer, |
|
|
|
IDistributedCacheKeyNormalizer keyNormalizer, |
|
|
|
IServiceScopeFactory serviceScopeFactory, |
|
|
|
IUnitOfWorkManager unitOfWorkManager) : base( |
|
|
|
distributedCacheOption: distributedCacheOption, |
|
|
|
cache: cache, |
|
|
|
cancellationTokenProvider: cancellationTokenProvider, |
|
|
|
serializer: serializer, |
|
|
|
keyNormalizer: keyNormalizer, |
|
|
|
serviceScopeFactory: serviceScopeFactory, |
|
|
|
unitOfWorkManager: unitOfWorkManager) |
|
|
|
public IDistributedCache<TCacheItem, string> InternalCache { get; } |
|
|
|
|
|
|
|
public DistributedCache(IDistributedCache<TCacheItem, string> internalCache) |
|
|
|
{ |
|
|
|
InternalCache = internalCache; |
|
|
|
} |
|
|
|
|
|
|
|
public TCacheItem Get(string key, bool? hideErrors = null, bool considerUow = false) |
|
|
|
{ |
|
|
|
return InternalCache.Get(key, hideErrors, considerUow); |
|
|
|
} |
|
|
|
|
|
|
|
public KeyValuePair<string, TCacheItem>[] GetMany(IEnumerable<string> keys, bool? hideErrors = null, bool considerUow = false) |
|
|
|
{ |
|
|
|
return InternalCache.GetMany(keys, hideErrors, considerUow); |
|
|
|
} |
|
|
|
|
|
|
|
public Task<KeyValuePair<string, TCacheItem>[]> GetManyAsync(IEnumerable<string> keys, bool? hideErrors = null, bool considerUow = false, CancellationToken token = default) |
|
|
|
{ |
|
|
|
return InternalCache.GetManyAsync(keys, hideErrors, considerUow, token); |
|
|
|
} |
|
|
|
|
|
|
|
public Task<TCacheItem> GetAsync(string key, bool? hideErrors = null, bool considerUow = false, CancellationToken token = default) |
|
|
|
{ |
|
|
|
return InternalCache.GetAsync(key, hideErrors, considerUow, token); |
|
|
|
} |
|
|
|
|
|
|
|
public TCacheItem GetOrAdd(string key, Func<TCacheItem> factory, Func<DistributedCacheEntryOptions> optionsFactory = null, bool? hideErrors = null, bool considerUow = false) |
|
|
|
{ |
|
|
|
return InternalCache.GetOrAdd(key, factory, optionsFactory, hideErrors, considerUow); |
|
|
|
} |
|
|
|
|
|
|
|
public Task<TCacheItem> GetOrAddAsync(string key, Func<Task<TCacheItem>> factory, Func<DistributedCacheEntryOptions> optionsFactory = null, bool? hideErrors = null, bool considerUow = false, CancellationToken token = default) |
|
|
|
{ |
|
|
|
return InternalCache.GetOrAddAsync(key, factory, optionsFactory, hideErrors, considerUow, token); |
|
|
|
} |
|
|
|
|
|
|
|
public KeyValuePair<string, TCacheItem>[] GetOrAddMany(IEnumerable<string> keys, Func<IEnumerable<string>, List<KeyValuePair<string, TCacheItem>>> factory, Func<DistributedCacheEntryOptions> optionsFactory = null, bool? hideErrors = null, bool considerUow = false) |
|
|
|
{ |
|
|
|
return InternalCache.GetOrAddMany(keys, factory, optionsFactory, hideErrors, considerUow); |
|
|
|
} |
|
|
|
|
|
|
|
public Task<KeyValuePair<string, TCacheItem>[]> GetOrAddManyAsync(IEnumerable<string> keys, Func<IEnumerable<string>, Task<List<KeyValuePair<string, TCacheItem>>>> factory, Func<DistributedCacheEntryOptions> optionsFactory = null, bool? hideErrors = null, bool considerUow = false, CancellationToken token = default) |
|
|
|
{ |
|
|
|
return InternalCache.GetOrAddManyAsync(keys, factory, optionsFactory, hideErrors, considerUow, token); |
|
|
|
} |
|
|
|
|
|
|
|
public void Set(string key, TCacheItem value, DistributedCacheEntryOptions options = null, bool? hideErrors = null, bool considerUow = false) |
|
|
|
{ |
|
|
|
InternalCache.Set(key, value, options, hideErrors, considerUow); |
|
|
|
} |
|
|
|
|
|
|
|
public Task SetAsync(string key, TCacheItem value, DistributedCacheEntryOptions options = null, bool? hideErrors = null, bool considerUow = false, CancellationToken token = default) |
|
|
|
{ |
|
|
|
return InternalCache.SetAsync(key, value, options, hideErrors, considerUow, token); |
|
|
|
} |
|
|
|
|
|
|
|
public void SetMany(IEnumerable<KeyValuePair<string, TCacheItem>> items, DistributedCacheEntryOptions options = null, bool? hideErrors = null, bool considerUow = false) |
|
|
|
{ |
|
|
|
InternalCache.SetMany(items, options, hideErrors, considerUow); |
|
|
|
} |
|
|
|
|
|
|
|
public Task SetManyAsync(IEnumerable<KeyValuePair<string, TCacheItem>> items, DistributedCacheEntryOptions options = null, bool? hideErrors = null, bool considerUow = false, CancellationToken token = default) |
|
|
|
{ |
|
|
|
return InternalCache.SetManyAsync(items, options, hideErrors, considerUow, token); |
|
|
|
} |
|
|
|
|
|
|
|
public void Refresh(string key, bool? hideErrors = null) |
|
|
|
{ |
|
|
|
InternalCache.Refresh(key, hideErrors); |
|
|
|
} |
|
|
|
|
|
|
|
public Task RefreshAsync(string key, bool? hideErrors = null, CancellationToken token = default) |
|
|
|
{ |
|
|
|
return InternalCache.RefreshAsync(key, hideErrors, token); |
|
|
|
} |
|
|
|
|
|
|
|
public void RefreshMany(IEnumerable<string> keys, bool? hideErrors = null) |
|
|
|
{ |
|
|
|
InternalCache.RefreshMany(keys, hideErrors); |
|
|
|
} |
|
|
|
|
|
|
|
public Task RefreshManyAsync(IEnumerable<string> keys, bool? hideErrors = null, CancellationToken token = default) |
|
|
|
{ |
|
|
|
return InternalCache.RefreshManyAsync(keys, hideErrors, token); |
|
|
|
} |
|
|
|
|
|
|
|
public void Remove(string key, bool? hideErrors = null, bool considerUow = false) |
|
|
|
{ |
|
|
|
InternalCache.Remove(key, hideErrors, considerUow); |
|
|
|
} |
|
|
|
|
|
|
|
public Task RemoveAsync(string key, bool? hideErrors = null, bool considerUow = false, CancellationToken token = default) |
|
|
|
{ |
|
|
|
return InternalCache.RemoveAsync(key, hideErrors, considerUow, token); |
|
|
|
} |
|
|
|
|
|
|
|
public void RemoveMany(IEnumerable<string> keys, bool? hideErrors = null, bool considerUow = false) |
|
|
|
{ |
|
|
|
InternalCache.RemoveMany(keys, hideErrors, considerUow); |
|
|
|
} |
|
|
|
|
|
|
|
public Task RemoveManyAsync(IEnumerable<string> keys, bool? hideErrors = null, bool considerUow = false, |
|
|
|
CancellationToken token = default) |
|
|
|
{ |
|
|
|
return InternalCache.RemoveManyAsync(keys, hideErrors, considerUow, token); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|