memo-swap!
function
clojure.core.memoize/memo-swap!
(memo-swap! [f base] [f swap-fn args & results])The 2-arity version takes a core.memo-populated function and a map and
replaces the memoization cache with the supplied map. Use `memo-reset!`
instead for replacing the cache as this 2-arity version of `memo-swap!`
should be considered deprecated.
The 3+-arity version takes a core.memo-populated function and arguments
similar to what you would pass to `clojure.core/swap!` and performs a
`swap!` on the underlying cache. In order to satisfy core.memoize's
world view, the assumption is that you will generally be calling it like:
(def id (memo identity))
(memo-swap! id clojure.core.cache/miss [13] :omg)
(id 13)
;=> :omg
You'll nearly always use `clojure.core.cache/miss` for this operation but
you could pass any function that would work on an immutable cache, such
as `evict` or `assoc` etc.
Be aware that `memo-swap!` assumes it can wrap each of the `results` values
in a `delay` so that items conform to `clojure.core.memoize`'s world view.
Examples
No examples yet. Be the first to add one!