/// <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)
        {
            if(properties == null)
                throw new ArgumentNullException("properties");

            StorageProviderBase cacheStorage = null;
            try
            {
                string scheme = "heap";
                IDictionary schemeProps = (IDictionary)properties[scheme];

                if (scheme.CompareTo("heap") == 0)
                {
                    cacheStorage = new ClrHeapStorageProvider(schemeProps, evictionEnabled, NCacheLog);
                }

                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;
        }
Exemple #2
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);
        }
Exemple #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)
        {
            if (properties == null)
            {
                throw new ArgumentNullException("properties");
            }

            StorageProviderBase cacheStorage = null;

            try
            {
                string      scheme      = "heap";
                IDictionary schemeProps = (IDictionary)properties[scheme];

                if (scheme.CompareTo("heap") == 0)
                {
                    cacheStorage = new ClrHeapStorageProvider(schemeProps, evictionEnabled, NCacheLog);
                }

                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);
        }