Esempio n. 1
0
        public static bool Contains(GenericCacheObject obj)
        {
            if (obj.Key == "")
                return false;

            lock (Synchronizer)
            {
                return ContainsKey(obj.Key);
            }
        }
        public static bool Contains(GenericCacheObject obj)
        {
            if (obj.Key == "")
            {
                return(false);
            }

            lock (Synchronizer)
            {
                return(ContainsKey(obj.Key));
            }
        }
Esempio n. 3
0
        public static bool AddToBlacklist(GenericCacheObject obj)
        {
            if (string.IsNullOrWhiteSpace(obj.Key))
                return false;

            lock (Synchronizer)
            {
                if (ContainsKey(obj.Key))
                    return false;
                DataCache.Add(obj.Key, obj);
                ExpireCache.Add(obj.Expires, obj.Key);
                return true;
            }
        }
Esempio n. 4
0
        public static bool UpdateObject(GenericCacheObject obj)
        {
            if (string.IsNullOrWhiteSpace(obj.Key))
                return false;

            lock (Synchronizer)
            {
                RemoveObject(obj.Key);

                DataCache.Add(obj.Key, obj);
                ExpireCache.Add(obj.Expires, obj.Key);

                return true;
            }
        }
        public static bool UpdateObject(GenericCacheObject obj)
        {
            if (string.IsNullOrWhiteSpace(obj.Key))
            {
                return(false);
            }

            lock (Synchronizer)
            {
                RemoveObject(obj.Key);

                DataCache.Add(obj.Key, obj);
                ExpireCache.Add(obj.Expires, obj.Key);

                return(true);
            }
        }
        public static bool AddToBlacklist(GenericCacheObject obj)
        {
            if (string.IsNullOrWhiteSpace(obj.Key))
            {
                return(false);
            }

            lock (Synchronizer)
            {
                if (ContainsKey(obj.Key))
                {
                    return(false);
                }
                DataCache.Add(obj.Key, obj);
                ExpireCache.Add(obj.Expires, obj.Key);
                return(true);
            }
        }
        public static bool RemoveObject(string key)
        {
            if (string.IsNullOrWhiteSpace(key))
            {
                return(false);
            }

            lock (Synchronizer)
            {
                if (!ContainsKey(key))
                {
                    return(false);
                }
                GenericCacheObject oldObj = DataCache[key];
                DataCache.Remove(key);
                ExpireCache.Remove(oldObj.Expires);
                return(true);
            }
        }