/// <summary> /// Construtor padrão. /// </summary> /// <param name="cacheName">Nome do cache.</param> /// <param name="properties">Hash com as propriedades de configuração.</param> /// <param name="context">Contexto de execução.</param> /// <param name="timeout"></param> public DatasourceMgr(string cacheName, IDictionary properties, CacheRuntimeContext context, long timeout) { _cacheName = cacheName; _context = context; _queue = new Dictionary <object, IAsyncTask>(); this.Initialize(properties, timeout); }
/// <summary> /// Overloaded constructor. Takes the listener as parameter. /// </summary> /// <param name="listener">listener of Cache events.</param> public CacheBase(IDictionary properties, ICacheEventsListener listener, CacheRuntimeContext context) { _context = context; _listener = listener; _syncObj = new ReaderWriterLock(); _KeyLockManager = new KeyLockManager <object>(LockRecursionPolicy.SupportsRecursion); }
/// <summary> /// Overloaded constructor. Takes the properties as a map. /// </summary> /// <param name="cacheSchemes">collection of cache schemes (config properties).</param> /// <param name="properties">properties collection for this cache.</param> /// <param name="listener">cache events listener</param> /// <param name="timeSched">scheduler to use for periodic tasks</param> public LocalCache(IDictionary cacheClasses, CacheBase parentCache, IDictionary properties, ICacheEventsListener listener, CacheRuntimeContext context) : base(properties, parentCache, listener, context) { _stats.ClassName = "local-cache"; Initialize(cacheClasses, properties); }
public WriteThruProviderManager(string cacheName, IDictionary properties, CacheRuntimeContext context, int timeout, string providerName) { _context = context; _cacheName = cacheName; _myProvider = providerName; this.Initialize(properties); }
internal virtual void ResetVariant(CacheRuntimeContext context) { if (this.IsVariant) { Reset(context); } }
internal CPUUsageCollector(ResourceAtribute attribute, CacheRuntimeContext cacheRuntimeContext) : base(attribute, cacheRuntimeContext) { try { CouneterName = "% Processor Time"; Name = "CPU Usage"; if (!ServiceConfiguration.PublishCountersToCacheHost) { InitializeCounter(); } else { InitiliazeCPUNETCORE(); } processrs = Environment.ProcessorCount; if (processrs <= 0) { processrs = 1; } SetThresholds(); } catch (Exception ex) { } }
/// <summary> /// Overloaded constructor. Takes the properties as a map. /// </summary> /// <param name="cacheSchemes">collection of cache schemes (config properties).</param> /// <param name="properties">properties collection for this cache.</param> /// <param name="listener">cache events listener</param> /// <param name="timeSched">scheduler to use for periodic tasks</param> public IndexedLocalCache(IDictionary cacheClasses, CacheBase parentCache, IDictionary properties, ICacheEventsListener listener, CacheRuntimeContext context) : base(cacheClasses, parentCache, properties, listener, context) { IDictionary props = null; if (properties.Contains("indexes")) { props = properties["indexes"] as IDictionary; } _queryIndexManager = new QueryIndexManager(props, this, _context.CacheRoot.Name); if (!_queryIndexManager.Initialize()) _queryIndexManager = null; //+Numan16122014 _cacheStore.ISizableQueryIndexManager = _queryIndexManager; _cacheStore.ISizableEvictionIndexManager = _evictionPolicy; _cacheStore.ISizableExpirationIndexManager = _context.ExpiryMgr; _stats.MaxCount = _cacheStore.MaxCount; _stats.MaxSize = _cacheStore.MaxSize; //+Numan16122014 if (_context.PerfStatsColl != null) { if (_queryIndexManager != null) _context.PerfStatsColl.SetQueryIndexSize(_queryIndexManager.IndexInMemorySize); } }
/// <summary> /// Construtor padrão. /// </summary> /// <param name="properties">Propriedades de configuração.</param> /// <param name="context">Contexto de execução.</param> public ExpirationManager(IDictionary properties, CacheRuntimeContext context) { _context = context; _logger = context.Logger; this.Initialize(properties); _sleepInterval = ServiceConfiguration.ExpirationBulkRemoveDelay; _removeThreshhold = ServiceConfiguration.ExpirationBulkRemoveSize; }
internal AsyncItemReplicator(CacheRuntimeContext context, TimeSpan interval) { _bulkKeysToReplicate = ServiceConfiguration.BulkItemsToReplicate; this._context = context; this._interval = interval; _queue = new OptimizedQueue(context); }
public bool IsExpired(CacheRuntimeContext context) { if (_hint != null) { return(_hint.DetermineExpiration(context)); } return(false); }
/// <summary> /// Determina a expiração para o contexto. /// </summary> /// <param name="context"></param> /// <returns></returns> internal override bool DetermineExpiration(CacheRuntimeContext context) { if (_startAfter.CompareTo(CachingUtils.DiffSeconds(DateTime.Now)) > 0) { return(false); } return(base.HasExpired); }
public DSWriteBehindOperation(CacheRuntimeContext context, Object key, CacheEntry entry, OpCode opcode, string providerName, long operationDelay, string taskId, string source, WriteBehindAsyncProcessor.TaskState taskState) : base(context, key, entry, opcode, providerName) { this._taskId = taskId; this._state = taskState; this._source = source; this._delayInterval = operationDelay; }
internal AsyncItemReplicator(CacheRuntimeContext context, TimeSpan interval) { if (System.Configuration.ConfigurationSettings.AppSettings["NCacheServer.BulkItemsToReplicate"] != null) { _bulkKeysToReplicate = Convert.ToInt32(System.Configuration.ConfigurationSettings.AppSettings["NCacheServer.BulkItemsToReplicate"]); } this._context = context; this._interval = interval; }
/// <summary> /// Overloaded constructor /// Initializes the object based on the properties specified in configuration /// </summary> /// <param name="properties">properties collection for this cache.</param> public WriteThruProviderMgr(string cacheName, IDictionary properties, CacheRuntimeContext context, long operationDelay, string providerName) { _cacheName = cacheName; _context = context; _operationDelay = operationDelay; _myProvider = providerName; Initialize(properties); }
/// <summary> /// virtual method that returns true when the expiration has taken place, returns /// false otherwise. /// </summary> internal override bool DetermineExpiration(CacheRuntimeContext context) { if (_startAfter.CompareTo(DateTime.Now) > 0) { return(false); } return(HasExpired); }
/// <summary> /// Resets the value of the hint. Called by the Cache manager upon a successful HIT. /// </summary> internal virtual bool Reset(CacheRuntimeContext context) { _bits &= ~EXPIRED; if (_ncacheLog == null) { _ncacheLog = context.NCacheLog; } return(true); }
public DSWriteOperation(CacheRuntimeContext context, Object key, CacheEntry entry, OpCode opcode, string providerName) { this._key = key; this._entry = entry; this._opCode = opcode; this._providerName = providerName; this._cacheId = context.SerializationContext; this._context = context; }
internal NosDBDependencyListener(string key, string connString, string queryString, CacheRuntimeContext context, ExpirationHintType hintType, int timeOut = 0, IDictionary cmdParams = null) : base( key, connString, queryString, context.ExpiryMgr.NotifBasedDepManager, context.ExpiryMgr.NotifBasedDepManager, context.NCacheLog, hintType) { _cmdParams = cmdParams; _timeout = timeOut; }
internal NotificationBasedDependencyManager(CacheRuntimeContext context) { _context = context; _listeners = new Hashtable(); _silentListeners = new Hashtable(); _dbConPool = new DbConnectionPool(_context.NCacheLog); _asyncDepChange = new AsyncOnDepenencyChange(this); _asyncDepChange.Start(); }
internal YukonDependencyListener(string key, string connString, string queryString, CacheRuntimeContext context, ExpirationHintType hintType, CommandType cmdType, IDictionary cmdParams) : base(key, connString, queryString, context.ExpiryMgr.NotifBasedDepManager, context.ExpiryMgr.NotifBasedDepManager, context.NCacheLog, hintType) { _cmdParams = cmdParams; _cmdType = cmdType; _context = context; _notifBasedDepManager = _context.ExpiryMgr.NotifBasedDepManager; }
/// <summary> /// virtual method that returns true when the expiration has taken place, returns /// false otherwise. /// </summary> internal override bool DetermineExpiration(CacheRuntimeContext context) { if(HasExpired) return true; if (SortKey.CompareTo(AppUtil.DiffSeconds(DateTime.Now)) < 0) this.NotifyExpiration(this, null); return HasExpired; }
public CacheInputProvider(CacheBase source, QueryFilter filter, CacheRuntimeContext context) { this.queryFilter = filter; this.inputSource = source; this.context = context; if (this.context != null) { this.serializationContext = this.context.SerializationContext; } }
internal Subscriptions(string clientId, string subscriptionId, SubscriptionPolicyType subscriptionPolicy, long expirationTime, CacheRuntimeContext context, SubscriptionType subscriptionType = SubscriptionType.Subscriber) { _clientId = clientId; _subscriptionPolicy = subscriptionPolicy; _context = context; _expiration = IdleExpiration.Create(null, new TimeSpan(expirationTime)); _subscriptionType = subscriptionType; _expirationTime = expirationTime; }
/// <summary> /// Reset dependency settings /// </summary> /// <param name="context"></param> /// <returns></returns> internal override bool Reset(CacheRuntimeContext context) { base.Reset(context); // todo add manager code for handling NosDB dependency _notifBasedDepManager = context.ExpiryMgr.NotifBasedDepManager; if (_notifBasedDepManager != null) { return(_notifBasedDepManager.Add(CacheKey, _conStr, _queryStr, context.IsDbSyncCoordinator, _hintType, CommandType.Text, _cmdParams, _timeOut));// initialize if this node is DbSyncCoordinator } return(false); }
/// <summary> /// virtual method that returns true when the expiration has taken place, returns /// false otherwise. /// </summary> internal override bool DetermineExpiration(CacheRuntimeContext context) { if(HasExpired) return true; if (_absoluteTime < AppUtil.DiffSeconds(DateTime.Now)) this.NotifyExpiration(this, null); return HasExpired; }
/// <summary> /// Resets only the variant ExpirationHints. /// </summary> internal override void ResetVariant(CacheRuntimeContext context) { for (int i = 0; i < _hints.Count; i++) { ExpirationHint hint = (ExpirationHint)_hints[i]; if (hint.IsVariant) { hint.Reset(context); } } }
/// <summary> /// Overloaded Constructor /// </summary> /// <param name="timeSched"></param> public ExpirationManager(IDictionary properties, CacheRuntimeContext context) { _context = context; _ncacheLog = context.NCacheLog; Initialize(properties); //new way to do this... _sleepInterval = ServiceConfiguration.ExpirationBulkRemoveDelay; _removeThreshhold = ServiceConfiguration.ExpirationBulkRemoveSize; }
public void Execute(CacheBase cache, CacheRuntimeContext context, long count) { Sync.AcquireWriterLock(Timeout.Infinite); try { _evctPolicy.Execute(cache,context, count); } finally { Sync.ReleaseWriterLock(); } }
public void Execute(CacheBase cache, CacheRuntimeContext context, long count) { Sync.AcquireWriterLock(Timeout.Infinite); try { _evctPolicy.Execute(cache, context, count); } finally { Sync.ReleaseWriterLock(); } }
/// <summary> /// Determina a expiração. /// </summary> /// <param name="context"></param> /// <returns></returns> internal override bool DetermineExpiration(CacheRuntimeContext context) { if (base.HasExpired) { return(true); } if (this.SortKey.CompareTo(CachingUtils.DiffSeconds(DateTime.Now)) < 0) { base.NotifyExpiration(this, null); } return(base.HasExpired); }
/// <summary> /// Determina a data de expiração. /// </summary> /// <param name="context"></param> /// <returns></returns> internal override bool DetermineExpiration(CacheRuntimeContext context) { if (base.HasExpired) { return(true); } if (_absoluteTime < CachingUtils.DiffSeconds(DateTime.Now)) { base.NotifyExpiration(this, null); } return(base.HasExpired); }
/// <summary> /// Resets both the contained ExpirationHints. /// </summary> internal override bool Reset(CacheRuntimeContext context) { bool flag = base.Reset(context); for (int i = 0; i < _hints.Count; i++) { if (((ExpirationHint)_hints[i]).Reset(context)) { flag = true; } } return(flag); }
/// <summary> /// virtual method that returns true when the expiration has taken place, returns /// false otherwise. /// </summary> internal override bool DetermineExpiration(CacheRuntimeContext context) { if (_startAfter.CompareTo(DateTime.Now) > 0) { return false; } if(!HasExpired) { if(HasChanged) NotifyExpiration(this, null); } return HasExpired; }
/// <summary> /// Reset dependency settings /// </summary> /// <param name="context"></param> /// <returns></returns> internal override bool Reset(CacheRuntimeContext context) { base.Reset(context); _cdbSyncManager = context.ExpiryMgr.CacheDbSyncManager; _notifBasedDepManager = context.ExpiryMgr.NotifBasedDepManager; if (_notifBasedDepManager != null) { return(_notifBasedDepManager.Add(CacheKey, _conStr, _queryStr, context.IsDbSyncCoordinator, _hintType, _cmdType, _cmdParams, 0));// initialize if this node is DbSyncCoordinator } else { return(false); } }
/// <summary> /// Overloaded Constructor /// </summary> /// <param name="timeSched"></param> public ExpirationManager(IDictionary properties, CacheRuntimeContext context) { _context = context; _ncacheLog = context.NCacheLog; Initialize(properties); _cdbSyncMgr = new CacheDbSyncManager(_ncacheLog); _cdbSyncMgr.GetCacheID(context.CacheRoot.Name); _notifBasedDepMgr = new NotificationBasedDependencyManager(_context); _sleepInterval = ServiceConfiguration.ExpirationBulkRemoveDelay; _removeThreshhold = ServiceConfiguration.ExpirationBulkRemoveSize; }
/// <summary> /// Overloaded Constructor /// </summary> /// <param name="timeSched"></param> public ExpirationManager(IDictionary properties, CacheRuntimeContext context) { _context = context; _ncacheLog = context.NCacheLog; Initialize(properties); //muds: //new way to do this... _sleepInterval = Convert.ToInt32(ServiceConfiguration.ExpirationBulkRemoveDelay); _removeThreshhold = Convert.ToInt32(ServiceConfiguration.ExpirationBulkRemoveSize); }
/// <summary> /// Resets the value of the hint. Called by the Cache manager upon a successful HIT. /// </summary> internal virtual bool Reset(CacheRuntimeContext context) { _bits &= ~EXPIRED; if (_ncacheLog == null) _ncacheLog = context.NCacheLog; //return false; return true; }
public HashedOverflowCache(IDictionary cacheClasses, CacheBase parentCache, IDictionary properties, ICacheEventsListener listener, CacheRuntimeContext context, bool logEntries) : base(cacheClasses, parentCache, properties, listener, context) { _logMgr = new OpLogManager(logEntries, context); _logEntries = logEntries; }
/// <summary> /// /// </summary> /// <param name="cacheClasses"></param> /// <param name="properties"></param> /// <param name="listener"></param> /// <param name="context"></param> /// <param name="clusterListener"></param> /// <param name="userId"></param> /// <param name="password"></param> public ReplicatedServerCache(IDictionary cacheClasses, IDictionary properties, ICacheEventsListener listener, CacheRuntimeContext context, IClusterEventsListener clusterListener) : base(properties, listener, context, clusterListener) { _stats.ClassName = "replicated-server"; }
/// <summary> /// Overloaded constructor. Takes the listener as parameter. /// </summary> /// <param name="listener">listener of Cache events.</param> public CacheBase(IDictionary properties, ICacheEventsListener listener, CacheRuntimeContext context) { _context = context; _listener = listener; _syncObj = new ReaderWriterLock(); }
/// <summary> /// Overloaded Constructor /// </summary> /// <param name="timeSched"></param> public ExpirationManager(IDictionary properties, CacheRuntimeContext context) { _context = context; _ncacheLog = context.NCacheLog; Initialize(properties); //muds: //new way to do this... _sleepInterval = Convert.ToInt32(ServiceConfiguration.ExpirationBulkRemoveDelay); _removeThreshhold = Convert.ToInt32(ServiceConfiguration.ExpirationBulkRemoveSize); if (System.Configuration.ConfigurationSettings.AppSettings.Get("NCacheServer.EnableGCCollection") != null) { _allowExplicitGCCollection = Convert.ToBoolean(System.Configuration.ConfigurationSettings.AppSettings.Get("NCacheServer.EnableGCCollection")); } }
/// <summary> /// Overloaded constructor. Takes the listener as parameter. /// </summary> /// <param name="listener">listener of Cache events.</param> public ReplicatedCacheBase(IDictionary properties, ICacheEventsListener listener, CacheRuntimeContext context, IClusterEventsListener clusterListener) : base(properties, listener, context, clusterListener) { }
/// <summary> /// Overloaded constructor. Takes the properties as a map. /// </summary> /// <param name="cacheSchemes">collection of cache schemes (config properties).</param> /// <param name="properties">properties collection for this cache.</param> /// <param name="listener">cache events listener</param> /// <param name="timeSched">scheduler to use for periodic tasks</param> public IndexedOverflowCache(IDictionary cacheClasses, CacheBase parentCache, IDictionary properties, ICacheEventsListener listener, CacheRuntimeContext context) : base( cacheClasses, parentCache, properties, listener, context) { }
/// <summary> /// Constructor. /// </summary> /// <param name="cacheSchemes">collection of cache schemes (config properties).</param> /// <param name="properties">properties collection for this cache.</param> /// <param name="listener">cache events listener</param> public ReplicatedServerCache(IDictionary cacheClasses, IDictionary properties, ICacheEventsListener listener, CacheRuntimeContext context) : base(properties, listener, context) { _stats.ClassName = "replicated-server"; Initialize(cacheClasses, properties); }
/// <summary> /// Override this method for hints that should be reinitialized when they are moved to another partition. /// </summary> /// <param name="context">CacheRuntimeContex for required contextual information.</param> /// <returns>True if reinitialization was successfull.</returns> internal virtual bool ReInitializeHint(CacheRuntimeContext context) { return false; }
/// <summary> /// Overloaded constructor. Takes the listener as parameter. /// </summary> /// <param name="listener">listener of Cache events.</param> public ClusterCacheBase(IDictionary properties, ICacheEventsListener listener, CacheRuntimeContext context, IClusterEventsListener clusterListener) : base(properties, listener, context) { this._nodeInformationTable = Hashtable.Synchronized(new Hashtable(10)); _stats = new ClusterCacheStatistics(); _stats.InstanceName = _context.PerfStatsColl.InstanceName; _clusterListener = clusterListener; _nodeName = Environment.MachineName.ToLower(); }
/// <summary> /// Overloaded constructor. Takes the listener as parameter. /// </summary> /// <param name="listener">listener of Cache events.</param> public ClusterService(CacheRuntimeContext context, IClusterParticipant part, IDistributionPolicyMember distributionMbr, IClusterEventsListener listener) { _context = context; _participant = part; _distributionPolicyMbr = distributionMbr; _asynHandler = new ClusterOperationSynchronizer(this); _listener = listener; }
/// <summary> /// Overloaded constructor. Takes the listener as parameter. /// </summary> /// <param name="listener">listener of Cache events.</param> public ClusterService(CacheRuntimeContext context, IClusterParticipant part, IDistributionPolicyMember distributionMbr) { _context = context; _ncacheLog = context.NCacheLog; _participant = part; _distributionPolicyMbr = distributionMbr; _asynHandler = new ClusterOperationSynchronizer(this); }
/// <summary> /// Overloaded constructor. Takes the listener as parameter. /// </summary> /// <param name="properties"></param> /// <param name="listener"></param> /// <param name="timeSched"></param> /// <param name="asyncProcessor"></param> /// <param name="expiryMgr"></param> /// <param name="perfStatsColl"></param> public LocalCacheBase(IDictionary properties, CacheBase parentCache, ICacheEventsListener listener, CacheRuntimeContext context ) : base(properties, listener, context) { if (System.Configuration.ConfigurationSettings.AppSettings.Get("preparedQueryTableSize") != null) { _preparedQueryTableSize = Convert.ToInt32(System.Configuration.ConfigurationSettings.AppSettings.Get("preparedQueryTableSize")); } if (System.Configuration.ConfigurationSettings.AppSettings.Get("preparedQueryEvictionPercentage") != null) { _preparedQueryEvictionPercentage = Convert.ToInt32(System.Configuration.ConfigurationSettings.AppSettings.Get("preparedQueryEvictionPercentage")); } _stats = new CacheStatistics(); _stats.InstanceName = _context.PerfStatsColl.InstanceName; _parentCache = parentCache; }
/// <summary> /// virtual method that returns true when the expiration has taken place, returns /// false otherwise. /// </summary> internal virtual bool DetermineExpiration(CacheRuntimeContext context) { return HasExpired; }
/// <summary> /// virtual method that returns true when the expiration has taken place, returns /// false otherwise. Used only for those hints that are validated at the time of Get /// operation on the cache. /// </summary> /// <param name="context"></param> /// <returns></returns> internal virtual bool CheckExpired(CacheRuntimeContext context) { return false; }
public HashedLocalCache(IDictionary cacheClasses, CacheBase parentCache, IDictionary properties, ICacheEventsListener listener, CacheRuntimeContext context, bool logEntries) : base(cacheClasses, parentCache, properties, listener, context) { _logMgr = new OpLogManager(logEntries, context); _stats.LocalBuckets = new HashVector(); }
public bool IsExpired(CacheRuntimeContext context) { if (_hint != null) return _hint.DetermineExpiration(context); return false; }
public OpLogManager(bool logEnteries, CacheRuntimeContext context) { _logEnteries = logEnteries; _ncacheLog = context.NCacheLog; }
void IEvictionPolicy.Execute(CacheBase cache, CacheRuntimeContext context, long evictSize) { ILogger NCacheLog = cache.Context.NCacheLog; if (NCacheLog.IsInfoEnabled) NCacheLog.Info("LocalCache.Evict()", "Cache Size: {0}" + cache.Count.ToString()); //if user has updated the values in configuration file then new values will be reloaded. _sleepInterval = Convert.ToInt32(ServiceConfiguration.EvictionBulkRemoveDelay); _removeThreshhold = Convert.ToInt32(ServiceConfiguration.EvictionBulkRemoveSize); DateTime startTime = DateTime.Now; ArrayList selectedKeys = this.GetSelectedKeys(cache, (long)Math.Ceiling(evictSize * _ratio)); DateTime endTime = DateTime.Now; if (NCacheLog.IsInfoEnabled) NCacheLog.Info("LocalCache.Evict()", String.Format("Time Span for {0} Items: " + (endTime - startTime), selectedKeys.Count)); startTime = DateTime.Now; Cache rootCache = context.CacheRoot; ArrayList keysTobeRemoved = new ArrayList(); ArrayList dependentItems = new ArrayList(); ArrayList removedItems = null; IEnumerator e = selectedKeys.GetEnumerator(); int removedThreshhold = _removeThreshhold/300; int remIteration = 0; while (e.MoveNext()) { object key = e.Current; if (key == null) continue; keysTobeRemoved.Add(key); if (keysTobeRemoved.Count % 300 == 0) { try { OperationContext priorityEvictionOperationContext = new OperationContext(); priorityEvictionOperationContext.Add(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); removedItems = cache.RemoveSync(keysTobeRemoved.ToArray(), ItemRemoveReason.Underused, false, priorityEvictionOperationContext) as ArrayList; context.PerfStatsColl.IncrementEvictPerSecStatsBy(keysTobeRemoved.Count); } catch (Exception ex) { NCacheLog.Error("PriorityEvictionPolicy.Execute", "an error occured while removing items. Error " + ex.ToString()); } keysTobeRemoved.Clear(); if (removedItems != null && removedItems.Count > 0) { dependentItems.AddRange(removedItems); } remIteration++; if (remIteration >= removedThreshhold) { //put some delay so that user operations are not affected. System.Threading.Thread.Sleep(_sleepInterval*1000); remIteration = 0; } } } if (keysTobeRemoved.Count > 0) { try { OperationContext priorityEvictionOperationContext = new OperationContext(); priorityEvictionOperationContext.Add(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); removedItems = cache.RemoveSync(keysTobeRemoved.ToArray(), ItemRemoveReason.Underused, false, priorityEvictionOperationContext) as ArrayList; context.PerfStatsColl.IncrementEvictPerSecStatsBy(keysTobeRemoved.Count); if (removedItems != null && removedItems.Count > 0) { dependentItems.AddRange(removedItems); } } catch (Exception ex) { NCacheLog.Error("PriorityEvictionPolicy.Execute", "an error occured while removing items. Error " + ex.ToString()); } } if (dependentItems.Count > 0) { ArrayList removableList = new ArrayList(); if (rootCache != null) { foreach (object depenentItme in dependentItems) { if (depenentItme == null) continue; removableList.Add(depenentItme); if (removableList.Count % 100 == 0) { try { OperationContext priorityEvictionOperationContext = new OperationContext(); priorityEvictionOperationContext.Add(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); rootCache.CascadedRemove(removableList.ToArray(), ItemRemoveReason.Underused, true, priorityEvictionOperationContext); context.PerfStatsColl.IncrementEvictPerSecStatsBy(removableList.Count); } catch (Exception exc) { NCacheLog.Error("PriorityEvictionPolicy.Execute", "an error occured while removing dependent items. Error " + exc.ToString()); } removableList.Clear(); } } if (removableList.Count > 0) { try { OperationContext priorityEvictionOperationContext = new OperationContext(); priorityEvictionOperationContext.Add(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); rootCache.CascadedRemove(removableList.ToArray(), ItemRemoveReason.Underused, true, priorityEvictionOperationContext); context.PerfStatsColl.IncrementEvictPerSecStatsBy(removableList.Count); } catch (Exception exc) { NCacheLog.Error("PriorityEvictionPolicy.Execute", "an error occured while removing dependent items. Error " + exc.ToString()); } removableList.Clear(); } } } return; }
/// <summary> /// Overloaded constructor. Takes the listener as parameter. /// </summary> /// <param name="listener">listener of Cache events.</param> public PartitionedCacheBase(IDictionary properties, ICacheEventsListener listener, CacheRuntimeContext context) : base(properties, listener, context) { }
/// <summary> /// Resets the time to live counter. /// </summary> internal override bool Reset(CacheRuntimeContext context) { _lastTimeStamp = AppUtil.DiffSeconds(DateTime.Now); return base.Reset(context); }
/// <summary> /// Overloaded constructor. Takes the properties as a map. /// </summary> /// <param name="cacheSchemes">collection of cache schemes (config properties).</param> /// <param name="properties">properties collection for this cache.</param> /// <param name="listener">listener for the cache</param> /// <param name="timeSched">scheduler to use for periodic tasks</param> public OverflowCache(IDictionary cacheClasses, CacheBase parentCache, IDictionary properties, ICacheEventsListener listener, CacheRuntimeContext context) : base(properties, parentCache, listener, context) { _stats.ClassName = "overflow-cache"; Initialize(cacheClasses, properties); CacheStatistics pstat = _primary.Statistics, sstat = _secondary.Statistics; if(pstat.MaxCount == 0 || sstat.MaxCount == 0) _stats.MaxCount = 0; else _stats.MaxCount = pstat.MaxCount + sstat.MaxCount; }