예제 #1
0
        /// <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));
        }
예제 #2
0
        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);
        }
예제 #3
0
 internal ScavengerTask(string cacheManagerName, 
                        CachingConfigurationView currentConfigurationData, 
                        CacheCapacityScavengingPolicy scavengingPolicy,
                        ICacheOperations cacheOperations)
 {
     this.scavengingPolicy = scavengingPolicy;
     this.cacheManagerName = cacheManagerName;
     this.currentConfigurationData = currentConfigurationData;
     this.cacheOperations = cacheOperations;
 }
예제 #4
0
 internal ScavengerTask(string cacheManagerName,
                        CachingConfigurationView currentConfigurationData,
                        CacheCapacityScavengingPolicy scavengingPolicy,
                        ICacheOperations cacheOperations)
 {
     this.scavengingPolicy         = scavengingPolicy;
     this.cacheManagerName         = cacheManagerName;
     this.currentConfigurationData = currentConfigurationData;
     this.cacheOperations          = cacheOperations;
 }
예제 #5
0
        private string GetDefaultInstanceName()
        {
            CachingConfigurationView view = new CachingConfigurationView(ConfigurationContext);

            return(view.GetDefaultCacheManager());
        }
예제 #6
0
 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));
        }
예제 #8
0
        private CacheStorageData GetCacheStorageData(string cacheManagerName)
        {
            CachingConfigurationView view = (CachingConfigurationView)CreateConfigurationView();

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

            return(view.GetCacheManagerData(name));
        }
예제 #10
0
 private string GetDefaultInstanceName()
 {
     CachingConfigurationView view = new CachingConfigurationView(ConfigurationContext);
     return view.GetDefaultCacheManager();
 }
예제 #11
0
        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;
        }
예제 #12
0
 /// <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);
 }