예제 #1
0
        /// <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
        /// <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);
        }