diff options
| author | Scott Ostler <scottbot9000@gmail.com> | 2011-02-22 22:43:12 -0500 |
|---|---|---|
| committer | Scott Ostler <scottbot9000@gmail.com> | 2011-02-22 22:43:12 -0500 |
| commit | d32249280579d0ec11a57b40a49b3389ca887847 (patch) | |
| tree | 46ad640fc8fde2071892162de3715de4b0c58050 | |
| parent | 92fc288f6200ff0c8943cde89c62f675862cb1fa (diff) | |
Remove unused ttl-memoize
| -rw-r--r-- | src/site.clj | 6 | ||||
| -rwxr-xr-x | src/utils.clj | 28 |
2 files changed, 0 insertions, 34 deletions
diff --git a/src/site.clj b/src/site.clj index 6fce880..beb8a73 100644 --- a/src/site.clj +++ b/src/site.clj @@ -459,12 +459,6 @@ WHERE user_id IN (assoc (stringify-and-escape entry) "score_ent" (score-to-entity (:score entry)))) - -(def directory-cache-ttl (minutes 10)) -(def memoized-lookup-recent-posts-tagless - (ttl-memoize lookup-recent-posts-tagless directory-cache-ttl)) - - (defn add-recent-posts [user-id users] (if-not (empty? users) (let [res (if user-id diff --git a/src/utils.clj b/src/utils.clj index c1a998c..bca60b3 100755 --- a/src/utils.clj +++ b/src/utils.clj @@ -431,34 +431,6 @@ where session is defined." `(if (is-super-vip? ~'session) ~e (unknown-page))) - -;; Time-expiry memoize -;; http://www.mail-archive.com/clojure@googlegroups.com/msg20038.html - -(defn expire-cached-results* [cached-results time-to-live] - "Expire items from the cached function results." - (into {} - (filter (fn [[k v]] - (> time-to-live - (- (System/currentTimeMillis) (:time v)))) cached-results))) - -(defn ttl-memoize - "Returns a memoized version of a referentially transparent function. The - memoized version of the function keeps a cache of the mapping from arguments - to results and, when calls with the same arguments are repeated often, has - higher performance at the expense of higher memory use. Cached results are - removed from the cache when their time to live value expires." - [function time-to-live] - (let [cached-results (atom {})] - (fn [& arguments] - (swap! cached-results expire-cached-results* time-to-live) - (if-let [entry (find @cached-results arguments)] - (:result (val entry)) - (let [result (apply function arguments)] - (swap! cached-results assoc arguments - { :result result :time (System/currentTimeMillis)}) - result))))) - ;; Misc index/sorting funcs (defn sort-by-index-in |
