コード例 #1
0
ファイル: CacheManager.cs プロジェクト: CrazyTiger/Test
        /// <summary>
        /// 
        /// </summary>
        /// <param name="realCache">Кэш.</param>
        /// <param name="backgroundScheduler">Фоновый сборщик.</param>
        /// <param name="pollTimer">Таймер для проверки ограничений.</param>
        public CacheManager(Cache realCache, BackgroundScheduler backgroundScheduler, ExpirationPollTimer pollTimer)
        {
            if (pollTimer == null) throw new ArgumentNullException("pollTimer");

            this.realCache = realCache;
            this.pollTimer = pollTimer;
            this.backgroundScheduler = backgroundScheduler;

            pollTimer.StartPolling(backgroundScheduler.ExpirationTimeoutExpired);
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: CrazyTiger/Test
        private void button1_Click(object sender, EventArgs e)
        {
            var applicationContainer = new BlockContainer();
            BlockRegister.Initialize(applicationContainer);
            var cachingBlock = new CachingBlock();

            BlockRegister.RegisterInstance<CachingBlock>(cachingBlock);

            var mBackingStore = new NullBackingStore();
            var mInstrumentationProvider = new NullCachingInstrumentationProvider();
            var dataCache = new Cache(mBackingStore, mInstrumentationProvider);
            var mExpirationTask = new ExpirationTask(dataCache, mInstrumentationProvider);
            var mScavengerTask = new ScavengerTask(1, 5, dataCache, mInstrumentationProvider);
            var mBackgroundScheduler = new BackgroundScheduler(mExpirationTask, mScavengerTask, mInstrumentationProvider);
            var mExpirationPollTimer = new ExpirationPollTimer(1000);
            var dataCacheManager = new CacheManager(dataCache, mBackgroundScheduler, mExpirationPollTimer);

            var mCachingBlock = BlockRegister.GetInstance<CachingBlock>();
            mCachingBlock.RegisterInstance("MyApplicationCache", dataCacheManager);
        }
コード例 #3
0
ファイル: CacheManager.cs プロジェクト: CrazyTiger/Test
        /// <summary>
        /// Создание кэш-менеджера, сохраняющего в памяти с пустым инструментарием
        /// </summary>
        /// <param name="numberToRemoveWhenScavenging">Число удаляемых элементов.</param>
        /// <param name="maximumElementsInCacheBeforeScavenging">Максимальное количество элементов до сбора.</param>
        /// <param name="expirationPollFrequencyInMilliSeconds">Временной интервал проверки ограничений (мс).</param>
        public CacheManager(int numberToRemoveWhenScavenging, int maximumElementsInCacheBeforeScavenging, int expirationPollFrequencyInMilliSeconds)
        {
            var mBackingStore = new NullBackingStore();
            var mInstrumentationProvider = new NullCachingInstrumentationProvider();
            var dataCache = new Cache(mBackingStore, mInstrumentationProvider);

            realCache = dataCache;

            var mExpirationPollTimer = new ExpirationPollTimer(expirationPollFrequencyInMilliSeconds);

            pollTimer = mExpirationPollTimer;

            var mExpirationTask = new ExpirationTask(dataCache, mInstrumentationProvider);
            var mScavengerTask = new ScavengerTask(numberToRemoveWhenScavenging, maximumElementsInCacheBeforeScavenging, dataCache, mInstrumentationProvider);
            var mBackgroundScheduler = new BackgroundScheduler(mExpirationTask, mScavengerTask, mInstrumentationProvider);

            backgroundScheduler = mBackgroundScheduler;

            pollTimer.StartPolling(backgroundScheduler.ExpirationTimeoutExpired);
        }
コード例 #4
0
ファイル: CacheManager.cs プロジェクト: CrazyTiger/Test
 public CacheManager(Cache realCache, BackgroundScheduler backgroundScheduler, ExpirationPollTimer pollTimer);