예제 #1
0
        /// <summary>
        /// Pooled queue cache is a cache of message that obtains resource from a pool
        /// </summary>
        /// <param name="cacheDataAdapter"></param>
        /// <param name="comparer"></param>
        /// <param name="logger"></param>
        /// <param name="cacheMonitor"></param>
        /// <param name="cacheMonitorWriteInterval">cache monitor write interval.  Only triggered for active caches.</param>
        public PooledQueueCache(ICacheDataAdapter <TQueueMessage, TCachedMessage> cacheDataAdapter, ICacheDataComparer <TCachedMessage> comparer, ILogger logger, ICacheMonitor cacheMonitor, TimeSpan?cacheMonitorWriteInterval)
        {
            if (cacheDataAdapter == null)
            {
                throw new ArgumentNullException("cacheDataAdapter");
            }
            if (comparer == null)
            {
                throw new ArgumentNullException("comparer");
            }
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }
            this.cacheDataAdapter = cacheDataAdapter;
            this.comparer         = comparer;
            this.logger           = logger;
            this.itemCount        = 0;
            pool              = new CachedMessagePool <TQueueMessage, TCachedMessage>(cacheDataAdapter);
            messageBlocks     = new LinkedList <CachedMessageBlock <TCachedMessage> >();
            this.cacheMonitor = cacheMonitor;

            if (this.cacheMonitor != null && cacheMonitorWriteInterval.HasValue)
            {
                this.periodicMonitoring = new PeriodicAction(cacheMonitorWriteInterval.Value, this.ReportCacheMessageStatistics);
            }
        }
예제 #2
0
        /// <summary>
        /// Pooled queue cache is a cache of message that obtains resource from a pool
        /// </summary>
        /// <param name="cacheDataAdapter"></param>
        /// <param name="comparer"></param>
        /// <param name="logger"></param>
        /// <param name="cacheMonitor"></param>
        /// <param name="cacheMonitorWriteInterval">cache monitor write interval</param>
        public PooledQueueCache(ICacheDataAdapter <TQueueMessage, TCachedMessage> cacheDataAdapter, ICacheDataComparer <TCachedMessage> comparer, Logger logger, ICacheMonitor cacheMonitor = null, TimeSpan?cacheMonitorWriteInterval = null)
        {
            if (cacheDataAdapter == null)
            {
                throw new ArgumentNullException("cacheDataAdapter");
            }
            if (comparer == null)
            {
                throw new ArgumentNullException("comparer");
            }
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }
            this.cacheDataAdapter = cacheDataAdapter;
            this.comparer         = comparer;
            this.logger           = logger.GetSubLogger("messagecache", "-");
            this.itemCount        = 0;
            pool              = new CachedMessagePool <TQueueMessage, TCachedMessage>(cacheDataAdapter);
            messageBlocks     = new LinkedList <CachedMessageBlock <TCachedMessage> >();
            this.cacheMonitor = cacheMonitor;

            if (this.cacheMonitor != null && cacheMonitorWriteInterval.HasValue)
            {
                this.timer = new Timer(this.ReportCacheMessageStatistics, null, cacheMonitorWriteInterval.Value, cacheMonitorWriteInterval.Value);
            }
        }
예제 #3
0
 public PooledQueueCache(ICacheDataAdapter <TQueueMessage, TCachedMessage> cacheDataAdapter)
 {
     if (cacheDataAdapter == null)
     {
         throw new ArgumentNullException("cacheDataAdapter");
     }
     this.cacheDataAdapter = cacheDataAdapter;
     pool          = new CachedMessagePool <TQueueMessage, TCachedMessage>(cacheDataAdapter);
     purgeQueue    = new ConcurrentQueue <IDisposable>();
     messageBlocks = new LinkedList <CachedMessageBlock <TQueueMessage, TCachedMessage> >();
 }
예제 #4
0
 /// <summary>
 /// Pooled queue cache is a cache of message that obtains resource from a pool
 /// </summary>
 /// <param name="cacheDataAdapter"></param>
 /// <param name="comparer"></param>
 /// <param name="logger"></param>
 public PooledQueueCache(ICacheDataAdapter <TQueueMessage, TCachedMessage> cacheDataAdapter, ICacheDataComparer <TCachedMessage> comparer, Logger logger)
 {
     if (cacheDataAdapter == null)
     {
         throw new ArgumentNullException("cacheDataAdapter");
     }
     if (comparer == null)
     {
         throw new ArgumentNullException("comparer");
     }
     if (logger == null)
     {
         throw new ArgumentNullException("logger");
     }
     this.cacheDataAdapter = cacheDataAdapter;
     this.comparer         = comparer;
     this.logger           = logger.GetSubLogger("messagecache", "-");
     pool          = new CachedMessagePool <TQueueMessage, TCachedMessage>(cacheDataAdapter);
     messageBlocks = new LinkedList <CachedMessageBlock <TCachedMessage> >();
 }