Exemplo n.º 1
0
        /// <summary>
        /// Overloaded constructor. Takes the properties as a map.
        /// </summary>
        /// <param name="properties">property collection</param>
        public StorageProviderBase(IDictionary properties, bool evictionEnabled, ILogger NCacheLog, IAlertPropagator alertPropagator)
        {
            Initialize(properties, evictionEnabled);
            _ncacheLog = NCacheLog;


            _alertPropagator = alertPropagator;

            string tmp;

            _evictionReportSize = ServiceConfiguration.CacheSizeThreshold;
            if (_evictionReportSize > 0)
            {
                _reportCacheNearEviction = true;
            }

            _reportInterval = ServiceConfiguration.CacheSizeReportInterval;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Overloaded constructor. Takes the properties as a map.
 /// </summary>
 /// <param name="properties">properties collection</param>
 public ClrHeapStorageProvider(IDictionary properties, bool evictionEnabled, ILogger NCacheLog, IAlertPropagator alertPropagator)
     : base(properties, evictionEnabled, NCacheLog, alertPropagator)
 {
     _evictionEnabled = evictionEnabled;
     _itemDict        = new HashVector(DEFAULT_CAPACITY, 0.7f);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Internal method that creates a cache store. A HashMap containing the config parameters
        /// is passed to this method.
        /// </summary>
        public static ICacheStorage CreateStorageProvider(IDictionary properties, string cacheContext, bool evictionEnabled, ILogger NCacheLog, IAlertPropagator alertPropagator)
        {
            if (properties == null)
            {
                throw new ArgumentNullException("properties");
            }

            StorageProviderBase cacheStorage = null;

            try
            {
                if (!properties.Contains("class"))
                {
                    throw new ConfigurationException("Missing cache store class.");
                }

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

                IDictionary schemeProps = (IDictionary)properties[scheme];

                if (scheme.CompareTo("heap") == 0)
                {
                    cacheStorage = new ClrHeapStorageProvider(schemeProps, evictionEnabled, NCacheLog, alertPropagator);
                }
                else if (scheme.CompareTo("memory") == 0)
                {
                    cacheStorage = new InMemoryStorageProvider(schemeProps, evictionEnabled);
                }
                else if (scheme.CompareTo("memory-mapped") == 0)
                {
                    cacheStorage = new MmfStorageProvider(schemeProps, evictionEnabled);
                }
                else if (scheme.CompareTo("file") == 0)
                {
                    cacheStorage = new FileSystemStorageProvider(schemeProps, evictionEnabled);
                }
                else
                {
                    throw new ConfigurationException("Invalid cache store class: " + scheme);
                }
                if (cacheStorage != null)
                {
                    cacheStorage.CacheContext = cacheContext;
                }
            }
            catch (ConfigurationException e)
            {
                Trace.error("CacheStorageFactory.CreateCacheStore()", e.ToString());
                throw;
            }
            catch (Exception e)
            {
                Trace.error("CacheStorageFactory.CreateCacheStore()", e.ToString());
                throw new ConfigurationException("Configuration Error: " + e.ToString(), e);
            }

            return(cacheStorage);
        }