/// <summary>
        /// <para>Gets the <see cref="Type"/> of the <see cref="CacheManager"/> for the factory to create.</para>
        /// </summary>
        /// <param name="cacheManagerName">
        /// <para>The name from configuration of the <see cref="CacheManager"/>.</para>
        /// </param>
        /// <returns>
        /// <para>The <see cref="Type"/> of the <see cref="CacheManager"/> to create.</para>
        /// </returns>
        protected override Type GetConfigurationType(string cacheManagerName)
        {
            CachingConfigurationView view             = new CachingConfigurationView(ConfigurationContext);
            CacheManagerData         cacheManagerData = view.GetCacheManagerData(cacheManagerName);

            return(GetType(cacheManagerData.TypeName));
        }
        private CacheManager CreateCacheManager(string cacheManagerName)
        {
            CacheManager cacheManager = cacheManagers[cacheManagerName] as CacheManager;

            if (cacheManager != null)
            {
                return(cacheManager);
            }

            CachingConfigurationView      view             = new CachingConfigurationView(ConfigurationContext);
            CacheManagerData              cacheManagerData = view.GetCacheManagerData(cacheManagerName);
            CacheCapacityScavengingPolicy scavengingPolicy =
                new CacheCapacityScavengingPolicy(cacheManagerName, view);

            IBackingStore backingStore = backingStoreFactory.CreateBackingStore(cacheManagerName);
            Cache         cache        = new Cache(backingStore, scavengingPolicy);

            ExpirationPollTimer timer          = new ExpirationPollTimer();
            ExpirationTask      expirationTask = CreateExpirationTask(cache);
            ScavengerTask       scavengerTask  = new ScavengerTask(cacheManagerName, view, scavengingPolicy, cache);
            BackgroundScheduler scheduler      = new BackgroundScheduler(expirationTask, scavengerTask);

            cache.Initialize(scheduler);

            scheduler.Start();
            timer.StartPolling(new TimerCallback(scheduler.ExpirationTimeoutExpired), cacheManagerData.ExpirationPollFrequencyInSeconds * 1000);

            cacheManager = new CacheManager(cache, scheduler, timer);
            cacheManagers.Add(cacheManagerName, cacheManager);
            return(cacheManager);
        }
Exemple #3
0
 internal ScavengerTask(string cacheManagerName, 
                        CachingConfigurationView currentConfigurationData, 
                        CacheCapacityScavengingPolicy scavengingPolicy,
                        ICacheOperations cacheOperations)
 {
     this.scavengingPolicy = scavengingPolicy;
     this.cacheManagerName = cacheManagerName;
     this.currentConfigurationData = currentConfigurationData;
     this.cacheOperations = cacheOperations;
 }
Exemple #4
0
 internal ScavengerTask(string cacheManagerName,
                        CachingConfigurationView currentConfigurationData,
                        CacheCapacityScavengingPolicy scavengingPolicy,
                        ICacheOperations cacheOperations)
 {
     this.scavengingPolicy         = scavengingPolicy;
     this.cacheManagerName         = cacheManagerName;
     this.currentConfigurationData = currentConfigurationData;
     this.cacheOperations          = cacheOperations;
 }
        private string GetDefaultInstanceName()
        {
            CachingConfigurationView view = new CachingConfigurationView(ConfigurationContext);

            return(view.GetDefaultCacheManager());
        }
 private CacheManagerData GetConfiguration(string id, IConfigurationSource configurationSource)
 {
     CachingConfigurationView view = new CachingConfigurationView(configurationSource);
     return view.GetCacheManagerData(id);
 }
        private CacheManagerData GetConfiguration(string id, IConfigurationSource configurationSource)
        {
            CachingConfigurationView view = new CachingConfigurationView(configurationSource);

            return(view.GetCacheManagerData(id));
        }
Exemple #8
0
        private CacheStorageData GetCacheStorageData(string cacheManagerName)
        {
            CachingConfigurationView view = (CachingConfigurationView)CreateConfigurationView();

            return(view.GetCacheStorageDataForCacheManager(cacheManagerName));
        }
Exemple #9
0
        protected override CacheManagerDataBase GetConfiguration(string name, IConfigurationSource configurationSource)
        {
            CachingConfigurationView view = new CachingConfigurationView(configurationSource);

            return(view.GetCacheManagerData(name));
        }
 private string GetDefaultInstanceName()
 {
     CachingConfigurationView view = new CachingConfigurationView(ConfigurationContext);
     return view.GetDefaultCacheManager();
 }
        private CacheManager CreateCacheManager(string cacheManagerName)
        {
            CacheManager cacheManager = cacheManagers[cacheManagerName] as CacheManager;
            if (cacheManager != null)
            {
                return cacheManager;
            }

            CachingConfigurationView view = new CachingConfigurationView(ConfigurationContext);
            CacheManagerData cacheManagerData = view.GetCacheManagerData(cacheManagerName);
            CacheCapacityScavengingPolicy scavengingPolicy =
                new CacheCapacityScavengingPolicy(cacheManagerName, view);

            IBackingStore backingStore = backingStoreFactory.CreateBackingStore(cacheManagerName);
            Cache cache = new Cache(backingStore, scavengingPolicy);

            ExpirationPollTimer timer = new ExpirationPollTimer();
            ExpirationTask expirationTask = CreateExpirationTask(cache);
            ScavengerTask scavengerTask = new ScavengerTask(cacheManagerName, view, scavengingPolicy, cache);
            BackgroundScheduler scheduler = new BackgroundScheduler(expirationTask, scavengerTask);
            cache.Initialize(scheduler);

            scheduler.Start();
            timer.StartPolling(new TimerCallback(scheduler.ExpirationTimeoutExpired), cacheManagerData.ExpirationPollFrequencyInSeconds * 1000);

            cacheManager = new CacheManager(cache, scheduler, timer);
            cacheManagers.Add(cacheManagerName, cacheManager);
            return cacheManager;
        }
 /// <summary>
 /// <para>Gets the <see cref="Type"/> of the <see cref="CacheManager"/> for the factory to create.</para>
 /// </summary>
 /// <param name="cacheManagerName">
 /// <para>The name from configuration of the <see cref="CacheManager"/>.</para>
 /// </param>
 /// <returns>
 /// <para>The <see cref="Type"/> of the <see cref="CacheManager"/> to create.</para>
 /// </returns>
 protected override Type GetConfigurationType(string cacheManagerName)
 {
     CachingConfigurationView view = new CachingConfigurationView(ConfigurationContext);
     CacheManagerData cacheManagerData = view.GetCacheManagerData(cacheManagerName);
     return GetType(cacheManagerData.TypeName);
 }