Esempio n. 1
0
        public static bool UpdateObject(GenericCacheObject obj)
        {
            if (obj.Key == "")
                return false;
            try
            {
                lock (_Synchronizer)
                {
                    if (RemoveObject(obj.Key))
                    {
                        _dataCache.Add(obj.Key, obj);
                        if (!_expireCache.ContainsKey(obj.Expires))
                            _expireCache.Add(obj.Expires, obj.Key);

                        return true;
                    }
                    else
                    {
                        Logger.LogDebug("Unable to update Generic Cache Object {0}", obj);
                        return false;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.LogDebug("Unable to update Generic Cache Object {0}", obj);
                Logger.LogDebug(ex.ToString(), false);
                return false;
            }
        }
        public static bool UpdateObject(GenericCacheObject obj)
        {
            if (obj.Key == "")
            {
                return(false);
            }
            try
            {
                lock (_Synchronizer)
                {
                    if (RemoveObject(obj.Key))
                    {
                        _dataCache.Add(obj.Key, obj);
                        if (!_expireCache.ContainsKey(obj.Expires))
                        {
                            _expireCache.Add(obj.Expires, obj.Key);
                        }

                        return(true);
                    }
                    else
                    {
                        Logger.LogDebug("Unable to update Generic Cache Object {0}", obj);
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.LogDebug("Unable to update Generic Cache Object {0}", obj);
                Logger.LogDebug(ex.ToString(), false);
                return(false);
            }
        }
        public static bool Contains(GenericCacheObject obj)
        {
            if (obj.Key == "")
            {
                return(false);
            }

            lock (_Synchronizer)
            {
                return(ContainsKey(obj.Key));
            }
        }
Esempio n. 4
0
        public static bool AddToCache(GenericCacheObject obj)
        {
            if (obj.Key == "")
                return false;

            lock (_Synchronizer)
            {
                if (!ContainsKey(obj.Key))
                {
                    _dataCache.Add(obj.Key, obj);
                    if (!_expireCache.ContainsKey(obj.Expires))
                        _expireCache.Add(obj.Expires, obj.Key);
                    return true;
                }
                return false;
            }
        }
        public static bool RemoveObject(string key)
        {
            if (key == "")
            {
                return(false);
            }

            lock (_Synchronizer)
            {
                if (ContainsKey(key))
                {
                    GenericCacheObject oldObj = _dataCache[key];
                    _dataCache.Remove(key);
                    _expireCache.Remove(oldObj.Expires);
                    return(true);
                }
                return(false);
            }
        }
        public static bool AddToCache(GenericCacheObject obj)
        {
            if (obj.Key == "")
            {
                return(false);
            }

            lock (_Synchronizer)
            {
                if (!ContainsKey(obj.Key))
                {
                    _dataCache.Add(obj.Key, obj);
                    if (!_expireCache.ContainsKey(obj.Expires))
                    {
                        _expireCache.Add(obj.Expires, obj.Key);
                    }
                    return(true);
                }
                return(false);
            }
        }
Esempio n. 7
0
        public static bool Contains(GenericCacheObject obj)
        {
            if (obj.Key == "")
                return false;

            lock (_Synchronizer)
            {
                return ContainsKey(obj.Key);
            }
        }