private static void UpdateTagsDictionaryWithLock(object key, CacheTags tags) { foreach (var tag in tags) { lock (Locker) { UpdateTagsDictionary(key, tag); } } }
public static TItem Set <TItem>(this IMemoryCache cache, object key, TItem value, MemoryCacheEntryOptions options, CacheTags tags) { UpdateTagsDictionaryWithLock(key, tags); options.PostEvictionCallbacks.Add(PostEvictionCallbackRegistration); return(cache.Set(key, value, options)); }
public static TItem Set <TItem>(this IMemoryCache cache, object key, TItem value, IChangeToken expirationToken, CacheTags tags) { UpdateTagsDictionaryWithLock(key, tags); var options = GetMemoryCacheOptionsWithRegisteredCallback(); options.ExpirationTokens.Add(expirationToken); return(cache.Set(key, value, options)); }
public static TItem Set <TItem>(this IMemoryCache cache, object key, TItem value, TimeSpan absoluteExpirationRelativeToNow, CacheTags tags) { UpdateTagsDictionaryWithLock(key, tags); var options = GetMemoryCacheOptionsWithRegisteredCallback(); options.AbsoluteExpirationRelativeToNow = absoluteExpirationRelativeToNow; return(cache.Set(key, value, options)); }