From 75ed155dc944490186c75f90edc7a641fc02bfad Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sebasti=C3=A1n=20Bernardo=20Galkin?= <paraseba@gmail.com>
Date: Fri, 30 Mar 2012 10:49:31 -0300
Subject: [PATCH] Changed "limit" parameter name in TTLCache

limit is used in other caches to represent quantity, for TTL it
represents time. Using the same name was confusing
---
 src/main/clojure/clojure/core/cache.clj |   18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/main/clojure/clojure/core/cache.clj b/src/main/clojure/clojure/core/cache.clj
index 74fe146..7406785 100644
--- a/src/main/clojure/clojure/core/cache.clj
+++ b/src/main/clojure/clojure/core/cache.clj
@@ -227,7 +227,7 @@
 
 (declare key-killer)
 
-(defcache TTLCache [cache ttl limit]
+(defcache TTLCache [cache ttl ttl-ms]
   CacheProtocol
   (lookup [_ item]
     (get cache item))
@@ -237,31 +237,31 @@
     (when-let [t (get ttl item)]
       (< (- (System/currentTimeMillis)
             t)
-         limit)))
+         ttl-ms)))
   (hit [this item] this)
   (miss [this item result]
     (let [now  (System/currentTimeMillis)
-          kill-old (key-killer ttl limit now)]
+          kill-old (key-killer ttl ttl-ms now)]
       (TTLCache. (assoc (kill-old cache) item result)
                  (assoc (kill-old ttl) item now)
-                 limit)))
+                 ttl-ms)))
   (seed [_ base]
     (let [now (System/currentTimeMillis)]
       (TTLCache. base
                  (into {} (for [x base] [(key x) now]))
-                 limit)))
+                 ttl-ms)))
   (evict [_ key]
     (TTLCache. (dissoc cache key)
                (dissoc ttl key)
-               limit))
+               ttl-ms))
   Object
   (toString [_]
-    (str cache \, \space ttl \, \space limit)))
+    (str cache \, \space ttl \, \space ttl-ms)))
 
 
 (defn- key-killer
-  [ttl limit now]
-  (let [ks (map key (filter #(> (- now (val %)) limit)
+  [ttl ttl-ms now]
+  (let [ks (map key (filter #(> (- now (val %)) ttl-ms)
                             ttl))]
     #(apply dissoc % ks)))
 
-- 
1.7.9.5

