public static bool Contains(GenericCacheObject obj) { if (obj.Key == "") { return(false); } lock (s_synchronizer) { return(ContainsKey(obj.Key)); } }
public static bool UpdateObject(GenericCacheObject obj) { if (string.IsNullOrWhiteSpace(obj.Key)) { return(false); } lock (s_synchronizer) { RemoveObject(obj.Key); s_dataCache.Add(obj.Key, obj); AddToExpireCache(obj.Expires, obj.Key); return(true); } }
public static bool AddToBlacklist(GenericCacheObject obj) { if (string.IsNullOrWhiteSpace(obj.Key)) { return(false); } lock (s_synchronizer) { if (ContainsKey(obj.Key)) { return(false); } s_dataCache.Add(obj.Key, obj); AddToExpireCache(obj.Expires, obj.Key); return(true); } }
public static bool RemoveObject(string key) { if (string.IsNullOrWhiteSpace(key)) { return(false); } lock (s_synchronizer) { if (!ContainsKey(key)) { return(false); } GenericCacheObject oldObj = s_dataCache[key]; s_dataCache.Remove(key); RemoveFromExpireCache(oldObj.Expires, oldObj.Key); return(true); } }