示例#1
0
        /// <summary>Expire all cached objects && tag.</summary>
        public static void ExpireAll()
        {
            var tags = CacheTags.Select(x => x.Key).ToList();

            // We do not use ExpireTag because type doesn't have CachePrefix
            foreach (var tag in tags)
            {
                List <string> list;
                if (CacheTags.TryRemove(tag, out list))
                {
                    // never lock something related to this list elsewhere or ensure we don't create a deadlock
                    lock (list)
                    {
                        foreach (var item in list)
                        {
                            Cache.Remove(item);
                        }
                    }
                }
            }
        }