Beispiel #1
0
        /// <summary>
        /// Crée une nouvelle instance.
        /// </summary>
        private CacheManager()
        {
            _cacheDictionnary = new Dictionary <string, Cache>();
            _configElement    = (CacheManagerConfigElement)ConfigurationManager.GetSection(
                CacheManagerConfigElement.CacheElementName);

            if (_configElement == null)
            {
                _configElement = new CacheManagerConfigElement();
            }

            _defaultElement = _configElement.Caches[CacheConfigElement.DefaultCacheName];

            if (_defaultElement == null)
            {
                _defaultElement = new CacheConfigElement();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Crée un nouveau cache.
        /// </summary>
        /// <param name="cacheName">Nom du cache.</param>
        /// <returns>Cache.</returns>
        private Cache CreateCache(string cacheName)
        {
            CacheConfigElement element = _configElement.Caches[cacheName];

            if (element == null)
            {
                element = _defaultElement;
            }

            MemoryStoreEvictionPolicy policy = MemoryStoreEvictionPolicy.Lru;

            try {
                policy = (MemoryStoreEvictionPolicy)Enum.Parse(
                    typeof(MemoryStoreEvictionPolicy),
                    element.MemoryStoreEvictionPolicy);
            } catch (ArgumentException) {
                policy = MemoryStoreEvictionPolicy.Lru;
            }

            Cache cache = new Cache(
                cacheName,
                element.MaxElementsInMemory,
                policy,
                element.IsOverflowToDisk,
                _configElement.DiskStorePath,
                element.IsEternal,
                element.TimeToLiveSeconds,
                element.TimeToIdleSeconds,
                element.DiskPersistent,
                element.DiskExpiryThreadIntervalSeconds,
                element.MaxElementsOnDisk,
                element.DiskSpoolBufferSizeMB);

            cache.Init();
            return(cache);
        }