Beispiel #1
0
 private static void UpdateTagsDictionaryWithLock(object key, CacheTags tags)
 {
     foreach (var tag in tags)
     {
         lock (Locker)
         {
             UpdateTagsDictionary(key, tag);
         }
     }
 }
Beispiel #2
0
        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));
        }
Beispiel #3
0
        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));
        }
Beispiel #4
0
        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));
        }