Beispiel #1
0
        public bool Initialize(DatabaseContext _dbContext, CollectionConfiguration config)
        {
            //eviction is always enabled for now and can not be turned off.
            _isEvictionEnabled = true;
            if (_parent.CollectionConfiguration.EvictionConfiguration != null)  //TODO this check is added if eviction configuration is not available at collection level in db.config
            {
                //_isEvictionEnabled = _parent.CollectionConfiguration.EvictionConfiguration.EnabledEviction;
                if (_parent.CollectionConfiguration.EvictionConfiguration.Policy.ToLower() == "lru")
                {
                    _evictionPolicy = new LRUEvictionPolicy(_parent.DbContext.StatsIdentity);
                }
            }
            else
            {
                _evictionPolicy = new LRUEvictionPolicy(_parent.DbContext.StatsIdentity);
            }

            _persistenceManager = _parent.DbContext.PersistenceManager;
            _persistenceManager.AddMetadataIndex(_parent.Name, _parent.MetadataIndex);

            _indexManager = new CollectionIndexManager(_dbContext, _dbContext.IndexPersistanceManager, this, config.CollectionName);
            if (!_indexManager.Initialize(config.Indices))
            {
                return(false);
            }
            //if (_statsCollector != null)
            //    _statsCollector.SetStatsValue(StatisticsType.PendingPersistentDocuments, _dirtyDocuments.Count);

            if (_persistenceManager == null)
            {
                return(false);
            }
            return(true);
        }
Beispiel #2
0
 /// <summary>初始化 <see cref="T:System.Object" /> 类的新实例。</summary>
 protected BaseGenericObjectPool(BaseObjectPoolConfig baseObjectPoolConfig, IEvictionTimer timer = null)
 {
     this._timer                = timer ?? new EvictionTimer();
     _evictionPolicy            = new DefaultEvictionPolicy <T>();
     this._baseObjectPoolConfig = baseObjectPoolConfig ?? new BaseObjectPoolConfig();
     this.CreationStackTrace    = this.GetStackTrace(new Exception());
 }
Beispiel #3
0
 public NWaySetAssociativeCache(int n, ICacheIndexer <K> cacheIndexer)
 {
     CacheIndexer           = cacheIndexer;
     N                      = n;
     CacheMap               = new ConcurrentDictionary <int, CacheLine <K, V> >();
     EvictionPolicyInstance = new EvictionPolicy();
 }
        public SetAssociativeCache(int slotSize, int itemSize, IHashFunction <TKey> hashFunction = null, IEvictionPolicy <TKey, TValue> evictionPolicy = null)
        {
            // Assign the HashFunction implementation
            _hashFunction = hashFunction;
            if (hashFunction == null)
            {
                _hashFunction = new DefaultHashFunction <TKey>();
            }

            // Assign the EvictionPolicy implementation
            _evictionPolicy = evictionPolicy;
            if (evictionPolicy == null)
            {
                _evictionPolicy = new LruEviction <TKey, TValue>();
            }


            _hashTable = new Dictionary <int, IAssociativeCache <TKey, TValue> >(slotSize);
            _slotSize  = slotSize;
            _itemSize  = itemSize;


            // Initialize Slots
            for (int i = 0; i < _slotSize; i++)
            {
                _hashTable.Add(i, new AssociativeCache <TKey, TValue>(_itemSize, _evictionPolicy));
            }
        }
Beispiel #5
0
        /// <summary>
        /// Method that allows the object to initialize itself. Passes the property map down
        /// the object hierarchy so that other objects may configure themselves as well..
        /// </summary>
        /// <param name="properties">configuration properties</param>
        protected override void Initialize(IDictionary cacheClasses, IDictionary properties)
        {
            if (properties == null)
            {
                throw new ArgumentNullException("properties");
            }

            try
            {
                base.Initialize(cacheClasses, properties);

                _allowExplicitGCCollection = ServiceConfiguration.EnableGCCollection;

                if (!properties.Contains("storage"))
                {
                    throw new ConfigurationException("Missing configuration option 'storage'");
                }

                if (properties.Contains("scavenging-policy"))
                {
                    IDictionary evictionProps = properties["scavenging-policy"] as IDictionary;

                    if (Convert.ToDouble(evictionProps["evict-ratio"]) > 0)
                    {
                        _evictionPolicy = EvictionPolicyFactory.CreateEvictionPolicy(evictionProps, _context.NCacheLog);
                    }
                }
                else
                {
                    _evictionPolicy = EvictionPolicyFactory.CreateDefaultEvictionPolicy();
                }

                IDictionary storageProps = properties["storage"] as IDictionary;

                _cacheStore = CacheStorageFactory.CreateStorageProvider(storageProps, this._context.SerializationContext, _evictionPolicy != null, _context.NCacheLog, null);

                _cacheStore.ISizableMessageStore = _topicManager;
                _stats.MaxCount = _cacheStore.MaxCount;
                _stats.MaxSize  = _cacheStore.MaxSize;
            }
            catch (ConfigurationException e)
            {
                if (_context != null)
                {
                    _context.NCacheLog.Error("LocalCache.Initialize()", e.ToString());
                }
                Dispose();
                throw;
            }
            catch (Exception e)
            {
                if (_context != null)
                {
                    _context.NCacheLog.Error("LocalCache.Initialize()", e.ToString());
                }
                Dispose();
                throw new ConfigurationException("Configuration Error: " + e.ToString(), e);
            }
        }
Beispiel #6
0
 public AssociativeCache(int sets, int entries, IEvictionPolicy <K, V> evictionPolicy, IHashAlgorithm <K> hashAlgorithm)
 {
     _sets           = sets;
     _entries        = entries;
     _evictionPolicy = evictionPolicy;
     _hashAlgorithm  = hashAlgorithm;
     _cache          = new CacheItem <K, V> [sets * entries];
 }
        public AssociativeCache(long itemCapacity, IEvictionPolicy <TKey, TValue> evictionPolicy = null)
        {
            _evictionPolicy = evictionPolicy;
            if (_evictionPolicy == null)
            {
                _evictionPolicy = new LruEviction <TKey, TValue>();
            }

            _itemCapacity = itemCapacity;
            _items        = new Dictionary <TKey, CacheItem <TKey, TValue> >();
        }
        /// <summary>
        /// Cria uma política de liberação com base nas propriedades informadas.
        /// </summary>
        /// <param name="properties"></param>
        /// <returns></returns>
        public static IEvictionPolicy CreateEvictionPolicy(IDictionary properties)
        {
            properties.Require("properties").NotNull();
            IEvictionPolicy policy2;

            try
            {
                float ratio = 0f;
                if (properties.Contains("evict-ratio"))
                {
                    CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
                    Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
                    ratio = Convert.ToSingle(properties["evict-ratio"]);
                    Thread.CurrentThread.CurrentCulture = currentCulture;
                }
                IEvictionPolicy policy     = null;
                string          str        = Convert.ToString(properties["class"]).ToLower();
                IDictionary     dictionary = (IDictionary)properties[str];
                string          str2       = str;
                if (str2 != null)
                {
                    if (!(str2 == "lru"))
                    {
                        if (str2 == "lfu")
                        {
                            policy = new LFUEvictionPolicy(dictionary, ratio);
                        }
                        if (str2 == "priority")
                        {
                            policy = new PriorityEvictionPolicy(dictionary, ratio);
                        }
                    }
                    else
                    {
                        policy = new LRUEvictionPolicy(dictionary, ratio);
                    }
                }
                if (policy == null)
                {
                    throw new Colosoft.Caching.Exceptions.ConfigurationException("Invalid Eviction Policy: " + str);
                }
                policy2 = policy;
            }
            catch (Colosoft.Caching.Exceptions.ConfigurationException)
            {
                throw;
            }
            catch (Exception exception)
            {
                throw new Colosoft.Caching.Exceptions.ConfigurationException("EvictionPolicyFactory.CreateEvictionPolicy(): " + exception.ToString());
            }
            return(policy2);
        }
Beispiel #9
0
        public Cache(IEqualityComparer <TKey> keyComparer, IEvictionPolicy evictionPolicy, int?initialCapacity = null)
        {
            // Cache timestamps are only precise to the second, so truncate the epoch to the last second.
            DateTimeOffset now   = DateTimeOffset.Now;
            long           ticks = now.Ticks / TimeSpan.TicksPerSecond * TimeSpan.TicksPerSecond;

            _epoch = new DateTimeOffset(ticks, now.Offset);

            _keyComparer    = keyComparer;
            _evictionPolicy = evictionPolicy;
            int capacity = initialCapacity ?? DefaultInitialCapacity;

            InitArrays(capacity, out _bucketHeads, out _keys, out _items, out _entries);
        }
        /// <summary>
        /// Internal method that creates a cache policy. A HashMap containing the config parameters
        /// is passed to this method.
        /// </summary>
        public static IEvictionPolicy CreateEvictionPolicy(IDictionary properties, ILogger logger)
        {
            if (properties == null)
            {
                throw new ArgumentNullException("properties");
            }

            try
            {
                float evictRatio = 0;
                if (properties.Contains("evict-ratio"))
                {
                    CultureInfo thisCult = Thread.CurrentThread.CurrentCulture;     //get the currently applied culture.
                    Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); //change it to enUS
                    evictRatio = Convert.ToSingle(properties["evict-ratio"]);       //get the value out ...
                    Thread.CurrentThread.CurrentCulture = thisCult;                 //revert back the original culture.
                }

                IEvictionPolicy evictionPolicy = null;

                string scheme = "";

                scheme = Convert.ToString(properties["class"]);
                scheme = scheme.ToLower();


                IDictionary schemeProps = (IDictionary)properties[scheme];
                switch (scheme)
                {
                case "priority": evictionPolicy = new PriorityEvictionPolicy(schemeProps, evictRatio); break;
                }
                if (evictionPolicy == null)
                {
                    throw new ConfigurationException("Invalid Eviction Policy: " + scheme);
                }

                //return a thread safe eviction policy.
                return(evictionPolicy);
            }
            catch (ConfigurationException e)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new ConfigurationException("EvictionPolicyFactory.CreateEvictionPolicy(): " + e.ToString());
            }
        }
Beispiel #11
0
        /// <summary>
        /// Internal method that creates a cache policy. A HashMap containing the config parameters
        /// is passed to this method.
        /// </summary>
        public static IEvictionPolicy CreateEvictionPolicy(IDictionary properties)
        {
            if (properties == null)
            {
                throw new ArgumentNullException("properties");
            }

            try
            {
                float evictRatio = 0;
                if (properties.Contains("evict-ratio"))                             // for French Parsing error..
                {
                    CultureInfo thisCult = Thread.CurrentThread.CurrentCulture;     //get the currently applied culture.
                    Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); //change it to enUS
                    evictRatio = Convert.ToSingle(properties["evict-ratio"]);       //get the value out ...
                    Thread.CurrentThread.CurrentCulture = thisCult;                 //revert back the original culture.
                }

                IEvictionPolicy evictionPolicy = null;

                string scheme = "";

                string tempscheme = Convert.ToString(properties["class"]);
                if (tempscheme.ToLower().Equals("priority"))
                {
                    scheme = tempscheme;
                }
                else
                {
                    throw new ConfigurationException("Eviction Policy " + tempscheme + " Not Supported in this Edition of NCache.");
                }
                IDictionary schemeProps = (IDictionary)properties[scheme];
                evictionPolicy = new PriorityEvictionPolicy(schemeProps, evictRatio);

                //return a thread safe eviction policy.
                return(evictionPolicy);
            }
            catch (ConfigurationException e)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new ConfigurationException("EvictionPolicyFactory.CreateEvictionPolicy(): " + e.ToString());
            }
        }
        /// <summary>
        /// Asserts that two configurations have the same properties.
        /// </summary>
        private static void AssertConfigsAreEqual(IEvictionPolicy x, IEvictionPolicy y)
        {
            if (x == null)
            {
                Assert.IsNull(y);
                return;
            }

            Assert.AreEqual(x.GetType(), y.GetType());

            var px = (EvictionPolicyBase)x;
            var py = (EvictionPolicyBase)y;

            Assert.AreEqual(px.BatchSize, py.BatchSize);
            Assert.AreEqual(px.MaxSize, py.MaxSize);
            Assert.AreEqual(px.MaxMemorySize, py.MaxMemorySize);
        }
Beispiel #13
0
 /// <summary>
 /// Inicializa a instancia.
 /// </summary>
 /// <param name="cacheClasses"></param>
 /// <param name="properties"></param>
 protected override void Initialize(IDictionary cacheClasses, IDictionary properties)
 {
     properties.Require("properties").NotNull();
     try
     {
         base.Initialize(cacheClasses, properties);
         if (!properties.Contains("storage"))
         {
             throw new Colosoft.Caching.Exceptions.ConfigurationException(ResourceMessageFormatter.Create(() => Properties.Resources.ConfigurationException_MissingOption, "storage").Format());
         }
         if (properties.Contains("scavenging-policy"))
         {
             IDictionary dictionary = properties["scavenging-policy"] as IDictionary;
             if ((dictionary.Contains("eviction-enabled") && Convert.ToBoolean(dictionary["eviction-enabled"])) && (Convert.ToDouble(dictionary["evict-ratio"]) > 0.0))
             {
                 _evictionPolicy = EvictionPolicyFactory.CreateEvictionPolicy(dictionary);
             }
         }
         else
         {
             _evictionPolicy = EvictionPolicyFactory.CreateDefaultEvictionPolicy();
         }
         IDictionary dictionary2 = properties["storage"] as IDictionary;
         _cacheStore = CacheStorageFactory.CreateStorageProvider(dictionary2, base._context.SerializationContext, _evictionPolicy != null, base._context.Logger);
     }
     catch (Colosoft.Caching.Exceptions.ConfigurationException exception)
     {
         if (base._context != null)
         {
             base._context.Logger.Error("LocalCache.Initialize()".GetFormatter(), exception.GetFormatter());
         }
         this.Dispose();
         throw;
     }
     catch (Exception exception2)
     {
         if (base._context != null)
         {
             base._context.Logger.Error("LocalCache.Initialize()".GetFormatter(), exception2.GetFormatter());
         }
         this.Dispose();
         throw new Colosoft.Caching.Exceptions.ConfigurationException("Configuration Error: " + exception2.ToString(), exception2);
     }
 }
Beispiel #14
0
        /// <summary>
        /// Internal method that creates a cache policy. A HashMap containing the config parameters
        /// is passed to this method.
        /// </summary>
        public static IEvictionPolicy CreateEvictionPolicy(IDictionary properties, ILogger logger)
        {
            if (properties == null)
            {
                throw new ArgumentNullException("properties");
            }

            try
            {
                float evictRatio = 0;
                if (properties.Contains("evict-ratio"))
                {
                    CultureInfo thisCult = Thread.CurrentThread.CurrentCulture;     //get the currently applied culture.
                    Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); //change it to enUS
                    evictRatio = Convert.ToSingle(properties["evict-ratio"]);       //get the value out ...
                    Thread.CurrentThread.CurrentCulture = thisCult;                 //revert back the original culture.
                }

                IEvictionPolicy evictionPolicy = null;

                string      scheme      = Convert.ToString(properties["class"]).ToLower();
                IDictionary schemeProps = (IDictionary)properties[scheme];

                evictionPolicy = new PriorityEvictionPolicy(schemeProps, evictRatio);

                if (evictionPolicy == null)
                {
                    throw new ConfigurationException("Invalid Eviction Policy: " + scheme);
                }

                FeatureUsageCollector.Instance.GetFeature(FeatureEnum.priority_eviction, FeatureEnum.eviction).UpdateUsageTime();
                return(evictionPolicy);
            }
            catch (ConfigurationException e)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new ConfigurationException("EvictionPolicyFactory.CreateEvictionPolicy(): " + e.ToString());
            }
        }
        /// <summary>
        /// Writes to the specified writer.
        /// </summary>
        internal static void Write(IBinaryRawWriter writer, IEvictionPolicy policy)
        {
            if (policy == null)
            {
                writer.WriteByte(0);
                return;
            }

            var p = policy as EvictionPolicyBase;

            if (p == null)
            {
                throw new NotSupportedException(
                          string.Format("Unsupported Eviction Policy: {0}. Only predefined eviction policy types " +
                                        "are supported: {1}, {2}", policy.GetType(), typeof(LruEvictionPolicy),
                                        typeof(FifoEvictionPolicy)));
            }

            writer.WriteByte(p is FifoEvictionPolicy ? (byte)1 : (byte)2);

            writer.WriteInt(p.BatchSize);
            writer.WriteInt(p.MaxSize);
            writer.WriteLong(p.MaxMemorySize);
        }
Beispiel #16
0
 public CacheLine(int capacity, IEvictionPolicy <K, V> evictionPolicy)
 {
     Capacity       = capacity;
     EvictionPolicy = evictionPolicy;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CustomEvictionAssociativeCache{TValue}"/> class.
 /// </summary>
 /// <param name="size">The size.</param>
 /// <param name="evictionPolicy">The eviction policy.</param>
 public CustomEvictionAssociativeCache(int size, IEvictionPolicy <TValue> evictionPolicy)
 {
     m_cacheSize      = size;
     m_evictionPolicy = evictionPolicy;
     m_container      = new List <CacheEntry <TValue> >();
 }
Beispiel #18
0
 public Cache(IEvictionPolicy <Key> evictionPolicy, IStorage <Key, Value> storage)
 {
     _evictionPolicy = evictionPolicy;
     _storage        = storage;
 }
        /// <summary>
        /// Writes to the specified writer.
        /// </summary>
        internal static void Write(IBinaryRawWriter writer, IEvictionPolicy policy)
        {
            if (policy == null)
            {
                writer.WriteByte(0);
                return;
            }

            var p = policy as EvictionPolicyBase;

            if (p == null)
            {
                throw new NotSupportedException(
                    string.Format("Unsupported Eviction Policy: {0}. Only predefined eviction policy types " +
                                  "are supported: {1}, {2}", policy.GetType(), typeof (LruEvictionPolicy),
                        typeof (FifoEvictionPolicy)));
            }

            writer.WriteByte(p is FifoEvictionPolicy ? (byte) 1 : (byte) 2);

            writer.WriteInt(p.BatchSize);
            writer.WriteInt(p.MaxSize);
            writer.WriteLong(p.MaxMemorySize);
        }
Beispiel #20
0
        void IEvictionPolicy.Notify(object key, EvictionHint oldhint, EvictionHint newHint)
        {
            //always use the new priority eviction hint.
            EvictionHint hint = newHint;

            if (hint != null)
            {
                CacheItemPriority hintPriority = ((PriorityEvictionHint)hint).Priority;

                if (hintPriority == CacheItemPriority.Default)
                {
                    hintPriority = this._priority;//set the default priority from the config.
                    ((PriorityEvictionHint)hint).Priority = this._priority;
                }

                if ((oldhint != null))
                {
                    CacheItemPriority oldPriority = ((PriorityEvictionHint)oldhint).Priority;
                    CacheItemPriority newPriority = ((PriorityEvictionHint)newHint).Priority;
                    if (oldPriority != newPriority)
                    {
                        IEvictionPolicy temp = this as IEvictionPolicy;
                        temp.Remove(key, oldhint);
                    }
                }

                lock (_index.SyncRoot)
                {
                    int changedIndex = -1;
                    switch (hintPriority)
                    {
                    case CacheItemPriority.Low:
                        if (_index[0] == null)
                        {
                            _index[0] = new Hashtable(25000, 0.7f);
                        }
                        _index[0][key] = hint;
                        changedIndex   = 0;
                        break;

                    case CacheItemPriority.BelowNormal:
                        if (_index[1] == null)
                        {
                            _index[1] = new Hashtable(25000, 0.7f);
                        }
                        _index[1][key] = hint;
                        changedIndex   = 1;
                        break;

                    case CacheItemPriority.Normal:
                        if (_index[2] == null)
                        {
                            _index[2] = new Hashtable(25000, 0.7f);
                        }
                        _index[2][key] = hint;
                        changedIndex   = 2;
                        break;

                    case CacheItemPriority.AboveNormal:
                        if (_index[3] == null)
                        {
                            _index[3] = new Hashtable(25000, 0.7f);
                        }
                        _index[3][key] = hint;
                        changedIndex   = 3;
                        break;

                    case CacheItemPriority.High:
                        if (_index[4] == null)
                        {
                            _index[4] = new Hashtable(25000, 0.7f);
                        }
                        _index[4][key] = hint;
                        changedIndex   = 4;
                        break;
                    }

                    if (changedIndex > -1 && _index[changedIndex].Count > _evictionIndexMaxCounts[changedIndex])
                    {
                        _evictionIndexMaxCounts[changedIndex] = _index[changedIndex].Count;
                    }
                }
            }
        }
 public EvictionPolicySyncWrapper(IEvictionPolicy evictionPolicy)
 {
     _evctPolicy = evictionPolicy;
 }
Beispiel #22
0
 public EvictionPolicySyncWrapper(IEvictionPolicy evictionPolicy)
 {
     _evctPolicy = evictionPolicy;
 }
Beispiel #23
0
 public RetryCache(IEvictionPolicy evictionPolicy)
 {
     _sharedResourceTimes = new Cache <TResource, long>(ResourceComparer, evictionPolicy);
     _userResourceTimes   = new Cache <ResourceBucket, long>(BucketComparer, evictionPolicy);
 }
Beispiel #24
0
 public AssociativeCache(int sets, IEvictionPolicy <K, V> evictionPolicy, IHashAlgorithm <K> hashAlgorithm)
     : this(sets, 1, evictionPolicy, hashAlgorithm)
 {
 }
Beispiel #25
0
 public ConcurrentCache(int size = DEFAUL_MAX_SIZE)
 {
     maxSize        = size;
     cacheMap       = new ConcurrentDictionary <string, string>();
     evictionPolicy = new LRUPolicy();
 }
Beispiel #26
0
        void IEvictionPolicy.Notify(object key, EvictionHint oldhint, EvictionHint newHint)
        {
            //always use the new priority eviction hint.
            EvictionHint hint = newHint;

            if (hint != null)
            {
                CacheItemPriority hintPriority = ((PriorityEvictionHint)hint).Priority;

                if (hintPriority == CacheItemPriority.Default)
                {
                    hintPriority = this._priority;//set the default priority from the config.
                    ((PriorityEvictionHint)hint).Priority = this._priority;
                }

                if ((oldhint != null))
                {
                    CacheItemPriority oldPriority = ((PriorityEvictionHint)oldhint).Priority;
                    CacheItemPriority newPriority = ((PriorityEvictionHint)newHint).Priority;
                    if (oldPriority != newPriority)
                    {
                        IEvictionPolicy temp = this as IEvictionPolicy;
                        temp.Remove(key, oldhint);
                    }
                }

                lock (_index.SyncRoot)
                {
                    switch (hintPriority)
                    {
                    case CacheItemPriority.Low:
                        if (_index[0] == null)
                        {
                            _index[0] = new HashVector();
                        }
                        _index[0][key] = hint;
                        break;

                    case CacheItemPriority.BelowNormal:
                        if (_index[1] == null)
                        {
                            _index[1] = new HashVector();
                        }
                        _index[1][key] = hint;
                        break;

                    case CacheItemPriority.Normal:
                        if (_index[2] == null)
                        {
                            _index[2] = new HashVector();
                        }
                        _index[2][key] = hint;
                        break;

                    case CacheItemPriority.AboveNormal:
                        if (_index[3] == null)
                        {
                            _index[3] = new HashVector();
                        }
                        _index[3][key] = hint;
                        break;

                    case CacheItemPriority.High:
                        if (_index[4] == null)
                        {
                            _index[4] = new HashVector();
                        }
                        _index[4][key] = hint;
                        break;
                    }
                }
            }
        }
Beispiel #27
0
        /// <summary>
        /// Method that allows the object to initialize itself. Passes the property map down 
        /// the object hierarchy so that other objects may configure themselves as well..
        /// </summary>
        /// <param name="properties">configuration properties</param>
        protected override void Initialize(IDictionary cacheClasses, IDictionary properties)
        {
            if (properties == null)
                throw new ArgumentNullException("properties");

            try
            {
                base.Initialize(cacheClasses, properties);

                if (System.Configuration.ConfigurationSettings.AppSettings.Get("NCache.EnableGCCollection") != null)
                {
                    _allowExplicitGCCollection = Convert.ToBoolean(System.Configuration.ConfigurationSettings.AppSettings.Get("NCache.EnableGCCollection"));
                }


                if (!properties.Contains("storage"))
                    throw new ConfigurationException("Missing configuration option 'storage'");

                if (properties.Contains("scavenging-policy"))
                {
                    IDictionary evictionProps = properties["scavenging-policy"] as IDictionary;

                    if (evictionProps != null && evictionProps.Contains("eviction-enabled"))
                        if (Convert.ToBoolean(evictionProps["eviction-enabled"]) && Convert.ToDouble(evictionProps["evict-ratio"]) > 0)
                            _evictionPolicy = EvictionPolicyFactory.CreateEvictionPolicy(evictionProps);

                }
                else
                {
                    _evictionPolicy = EvictionPolicyFactory.CreateDefaultEvictionPolicy();
                }


                IDictionary storageProps = properties["storage"] as IDictionary;               

				_cacheStore = CacheStorageFactory.CreateStorageProvider(storageProps, this._context.SerializationContext, _evictionPolicy != null, _context.NCacheLog);

                _stats.MaxCount = _cacheStore.MaxCount;
                _stats.MaxSize = _cacheStore.MaxSize;
            }
            catch (ConfigurationException e)
            {
               if (_context != null)
                {
                    _context.NCacheLog.Error("LocalCache.Initialize()",  e.ToString()); 
                }
                Dispose();
                throw;
            }
            catch (Exception e)
            {
				if (_context != null)
                {
                    _context.NCacheLog.Error("LocalCache.Initialize()",  e.ToString()); 
                }
                Dispose();
                throw new ConfigurationException("Configuration Error: " + e.ToString(), e);
            }
        }