From 03f5ed53522e812349a2d520c49ec20a5a5d128a Mon Sep 17 00:00:00 2001
From: Homer Strong <homer.strong@gmail.com>
Date: Fri, 29 Jun 2012 17:28:11 -0700
Subject: [PATCH] dyadic memo-clear! to only evict memoized values for input args

---
 src/main/clojure/clojure/core/memoize.clj |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/main/clojure/clojure/core/memoize.clj b/src/main/clojure/clojure/core/memoize.clj
index 352e0db..51b713d 100644
--- a/src/main/clojure/clojure/core/memoize.clj
+++ b/src/main/clojure/clojure/core/memoize.clj
@@ -81,13 +81,19 @@
   "Reaches into an unk-memoized function and clears the cache.  This is a
    destructive operation and should be used with care.
 
+   When the second argument is a vector of input arguments, clears cache
+   only for argument vector.
+
    Keep in mind that depending on what other threads or doing, an
    immediate call to `snapshot` may not yield an empty cache.  That's
    cool though, we've learned to deal with that stuff in Clojure by
    now."
-  [f]
-  (when-let [cache (cache-id f)]
-    (swap! cache (constantly (clojure.core.cache/seed @cache {})))))
+  ([f]
+     (when-let [cache (cache-id f)]
+       (swap! cache (constantly (clojure.core.cache/seed @cache {})))))
+  ([f args]
+     (when-let [cache (cache-id f)]
+       (swap! cache (constantly (clojure.core.cache/evict @cache args))))))
 
 (defn memo-swap!
   "Takes an unk-populated function and a map and replaces the memoization cache
-- 
1.7.1

