internal static bool Invalidate(KeysetId setId) { HashSet <string> sets; CacheKeySetContext cksc = GetKeysetContext(setId, false); if (cksc == null) { return(false); } lock (cksc.lck) { if (!CacheManager.TryGetCachedResult <HashSet <string> >(cksc.CacheSetKey, out sets)) { Log.Warning("Not expected situation. cache key set does not exists for setId:{0}", setId); RemoveKeysetContext(setId); return(false); } foreach (var key in sets) { CacheManager.Remove(key); } Log.Info("{0} key records invalidated from the keyset ({1})", sets.Count, setId); sets.Clear(); CacheManager.CacheObject(cksc.CacheSetKey, sets); } return(true); }
internal static CacheKeySetContext GetKeysetContext(KeysetId setId, bool createIfNotExists) { CacheKeySetContext cskc = null; lock (setLock) { if (!CacheSetKeys.TryGetValue(setId.SetId, out cskc)) { if (createIfNotExists) { cskc = new CacheKeySetContext(); cskc.CacheSetKey = "CS_" + Helper.Md5(Config.Get().CacheSetSalt + setId.SetId); CacheSetKeys.Add(setId.SetId, cskc); } } } return(cskc); }