/// <summary>Adds cache tags corresponding to a cached key in the CacheTags dictionary.</summary> /// <param name="cacheKey">The cache key.</param> /// <param name="tags">A variable-length parameters list containing tags corresponding to the <paramref name="cacheKey" />.</param> internal static void AddCacheTag(string cacheKey, params string[] tags) { foreach (var tag in tags) { CacheTags.AddOrUpdate(CachePrefix + tag, x => new List <string> { cacheKey }, (x, list) => { if (!list.Contains(cacheKey)) { list.Add(cacheKey); } return(list); }); } }
/// <summary>Adds cache tags corresponding to a cached key in the CacheTags dictionary.</summary> /// <param name="cacheKey">The cache key.</param> /// <param name="tags">A variable-length parameters list containing tags corresponding to the <paramref name="cacheKey" />.</param> internal static void AddCacheTag(string cacheKey, params string[] tags) { foreach (var tag in tags) { CacheTags.AddOrUpdate(CachePrefix + tag, x => new List <string> { cacheKey }, (x, list) => { lock (list) { // never lock something related to this list elsewhere or ensure we don't create a deadlock if (!list.Contains(cacheKey)) { list.Add(cacheKey); } } return(list); }); } }