public static IEnumerable <SecondCacheItemProperty> GetSecondCache(CacheCategory cc) { string CacheKey = string.Empty; IList <SecondCacheItemProperty> cache = new List <SecondCacheItemProperty>(); System.Collections.IDictionaryEnumerator enumerator = HttpRuntime.Cache.GetEnumerator(); while (enumerator.MoveNext()) { CacheKey = (string)enumerator.Key; switch (cc) { case CacheCategory.STD: if (CacheKey.StartsWith(CacheCategory.OPC.ToString()) || CacheKey.StartsWith(CacheCategory.OSC.ToString())) { continue; } cache.Add(GetCacheObjectProperty(CacheKey)); break; default: if (CacheKey.StartsWith(cc.ToString())) { cache.Add(GetCacheObjectProperty(CacheKey)); } break; } } return(cache); }
public static void DestroyCacheOfCategory(CacheCategory cc) { string key = cc.ToString() + "-"; System.Collections.IDictionaryEnumerator enumerator = HttpRuntime.Cache.GetEnumerator(); while (enumerator.MoveNext()) { var name = (string)enumerator.Key; switch (cc) { case CacheCategory.STD: if (name.StartsWith(CacheCategory.OPC.ToString()) || name.StartsWith(CacheCategory.OSC.ToString())) { continue; } break; case CacheCategory.OPC: case CacheCategory.OSC: if (!name.StartsWith(key)) { continue; } break; default: break; } HttpRuntime.Cache.Remove((string)enumerator.Key); } }