public EdamosUserManager( UserManager <ApplicationUser> userManager, ICombinedCache <ApplicationUser> cache) { _userManager = userManager ?? throw new ArgumentNullException(nameof(userManager)); _cache = cache ?? throw new ArgumentNullException(nameof(cache)); }
public ValuesController( IMemoryCache <MyCache> onlyMemoryCache, IDistributedCache <MyCache> onlyDistributedCache, ICombinedCache <MyCache> combinedCache) { mem = onlyMemoryCache ?? throw new ArgumentNullException(nameof(onlyMemoryCache)); dist = onlyDistributedCache ?? throw new ArgumentNullException(nameof(onlyDistributedCache)); comb = combinedCache ?? throw new ArgumentNullException(nameof(combinedCache)); }
public static TObject GetOrSetValue <TCacheInstance, TObject>( this ICombinedCache <TCacheInstance> cache, string key, Func <TObject> valueFactory, MemoryCacheEntryOptions memoryOptions = null, DistributedCacheEntryOptions disrtibutedOptions = null) where TObject : class { return(cache.MemoryCache.GetOrSetValue(key, () => cache.DistributedCache.GetOrSetValue(key, valueFactory, disrtibutedOptions), memoryOptions)); }
public static async Task RemoveAsync <TCacheInstance>(this ICombinedCache <TCacheInstance> cache, string key, CancellationToken token = default(CancellationToken)) { try { await cache.DistributedCache.RemoveAsync(key, token); } finally { cache.MemoryCache.Remove(key); } }
public static void Remove <TCacheInstance>(this ICombinedCache <TCacheInstance> cache, string key) { try { cache.DistributedCache.Remove(key); } finally { cache.MemoryCache.Remove(key); } }
public static Task <TObject> GetOrSetValueAsync <TCacheInstance, TObject>( this ICombinedCache <TCacheInstance> cache, string key, Func <Task <TObject> > valueFactory, MemoryCacheEntryOptions memoryOptions = null, DistributedCacheEntryOptions distributedOptions = null, CancellationToken token = default(CancellationToken)) where TObject : class { return(cache.MemoryCache.GetOrSetValueAsync(key, () => cache.DistributedCache.GetOrSetValueAsync(key, valueFactory, distributedOptions, token), memoryOptions)); }