[hyena] Fix LruCache item expiration



commit f15385c0a90472b7098190fe42b22552d126e54a
Author: Alexander Kojevnikov <alexander kojevnikov com>
Date:   Mon Mar 15 15:23:11 2010 +1100

    Fix LruCache item expiration
    
    We do want to have MaxCount items in the cache, not (MaxCount-1)

 src/Hyena/Hyena.Collections/LruCache.cs |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/src/Hyena/Hyena.Collections/LruCache.cs b/src/Hyena/Hyena.Collections/LruCache.cs
index ef80b23..a50e73c 100644
--- a/src/Hyena/Hyena.Collections/LruCache.cs
+++ b/src/Hyena/Hyena.Collections/LruCache.cs
@@ -91,7 +91,7 @@ namespace Hyena.Collections
                 misses++;
                 EnsureMinimumHitRatio ();
 
-                if (Count >= max_count) {
+                if (Count > max_count) {
                     TKey expire = FindOldestEntry ();
                     ExpireItem (cache[expire].Value);
                     cache.Remove (expire);
@@ -137,8 +137,8 @@ namespace Hyena.Collections
 
         private void EnsureMinimumHitRatio ()
         {
-            if (minimum_hit_ratio != null && Count >= MaxCount && HitRatio < minimum_hit_ratio) {
-                MaxCount = Count + 1;
+            if (minimum_hit_ratio != null && Count > MaxCount && HitRatio < minimum_hit_ratio) {
+                MaxCount = Count;
             }
         }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]