コード例 #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
ファイル: ScavengerTask.cs プロジェクト: bnantz/NCS-V1-1
 internal ScavengerTask(string cacheManagerName, 
                        CachingConfigurationView currentConfigurationData, 
                        CacheCapacityScavengingPolicy scavengingPolicy,
                        ICacheOperations cacheOperations)
 {
     this.scavengingPolicy = scavengingPolicy;
     this.cacheManagerName = cacheManagerName;
     this.currentConfigurationData = currentConfigurationData;
     this.cacheOperations = cacheOperations;
 }
コード例 #4
0
ファイル: ScavengerTask.cs プロジェクト: smillea1/NCS-V1-1
 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);
 }
コード例 #7
0
        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);
 }