(defcache FnCache [cache f]
CacheProtocol
(lookup [_ item]
(f (get cache item)))
(lookup [_ item not-found]
(let [ret (get cache item not-found)]
(if (= not-found ret)
not-found
(f ret))))
(has? [_ item]
(contains? cache item))
(hit [this item] this)
(miss [_ item result]
(BasicCache. (assoc cache item result)))
(evict [_ key]
(BasicCache. (dissoc cache key)))
(seed [_ base]
(BasicCache. base))
Object
(toString [_] (str cache)))