Exemple #1
0
 /// <summary>Constructor</summary>
 /// <param name="capacity">the normal item limit for cache (Count may exeed capacity due to minAge)</param>
 /// <param name="minAge">the minimium time after an access before an item becomes eligible for removal, during this time
 /// the item is protected and will not be removed from cache even if over capacity</param>
 /// <param name="maxAge">the max time that an object will sit in the cache without being accessed, before being removed</param>
 /// <param name="isValid">delegate used to determine if cache is out of date.  Called before index access not more than once per 10 seconds</param>
 public LRUCache(int capacity, TimeSpan minAge, TimeSpan maxAge, Func <bool> isValid = null)
 {
     _capacity  = capacity;
     _lifeSpan  = new LifespanMgr(this, minAge, maxAge);
     _indexList = new List <IIndex>();
     _isValid   = isValid;
 }
Exemple #2
0
 /// <summary>constructor</summary>
 public Node(LifespanMgr mgr, ItemType value)
 {
     _mgr  = mgr;
     Value = value;
     Interlocked.Increment(ref _mgr._owner._curCount);
     Touch();
 }
Exemple #3
0
        /// <summary>Constructor</summary>
        /// <param name="capacity">the normal item limit for cache (Count may exeed capacity due to minAge)</param>
        /// <param name="minAge">the minimium time after an access before an item becomes eligible for removal, during this time
        /// the item is protected and will not be removed from cache even if over capacity</param>
        /// <param name="maxAge">the max time that an object will sit in the cache without being accessed, before being removed</param>
        /// <param name="isValid">delegate used to determine if cache is out of date.  Called before index access not more than once per 10 seconds</param>
        public LruItemCache(int capacity, TimeSpan minAge, TimeSpan maxAge, IsValidFunc isValid)
        {
            if (capacity <= 0)
            {
                throw new ArgumentException("capacity MUST > 0");
            }

            _capacity = capacity;
            _isValid  = isValid;
            _lifeSpan = new LifespanMgr(this, minAge, maxAge);
        }
Exemple #4
0
 /// <summary>Constructor</summary>
 /// <param name="capacity">the normal item limit for cache (Count may exeed capacity due to minAge)</param>
 /// <param name="minAge">the minimium time after an access before an item becomes eligible for removal, during this time
 /// the item is protected and will not be removed from cache even if over capacity</param>
 /// <param name="maxAge">the max time that an object will sit in the cache without being accessed, before being removed</param>
 /// <param name="isValid">delegate used to determine if cache is out of date.  Called before index access not more than once per 10 seconds</param>
 public LruCache(int capacity, TimeSpan minAge, TimeSpan maxAge, IsValid isValid)
 {
     _capacity = capacity;
     _isValid  = isValid;
     _lifeSpan = new LifespanMgr(this, minAge, maxAge);
 }