Ejemplo 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;
            }
        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
0
        public static bool Contains(GenericCacheObject obj)
        {
            if (obj.Key == "")
            {
                return(false);
            }

            lock (_Synchronizer)
            {
                return(ContainsKey(obj.Key));
            }
        }
Ejemplo 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;
            }
        }
Ejemplo n.º 5
0
        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);
            }
        }
Ejemplo n.º 6
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);
            }
        }
Ejemplo n.º 7
0
        public static bool Contains(GenericCacheObject obj)
        {
            if (obj.Key == "")
                return false;

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