core.memoize is a new Clojure contrib library providing the following features:
An underlying PluggableMemoization
protocol that allows the use of customizable and swappable memoization caches that adhere to the synchronous CacheProtocol
found in core.cache
Memoization builders for implementations of common caching strategies, including:
clojure.core.memoize/fifo
)clojure.core.memoize/lru
)clojure.core.memoize/lu
)clojure.core.memoize/ttl
)memo
) that duplicates the functionality of Clojure's memoize
functionFunctions for manipulating the memoization cache of core.memoize
backed functions
Latest stable release: 0.5.8
Leiningen dependency information:
[org.clojure/core.memoize "0.5.8"]
Maven dependency information:
<dependency>
<groupId>org.clojure</groupId>
<artifactId>core.memoize</artifactId>
<version>0.5.8</version>
</dependency>
```clojure (ns my.cool.lib (:require clojure.core.memoize))
(def id (clojure.core.memoize/lu
#(do (Thread/sleep 5000) (identity %))
:lu/threshold 3))
(id 42)
; ... waits 5 seconds
;=> 42
(id 42)
; instantly
;=> 42
```
Refer to docstrings in the clojure.core.memoize
namespace for more information.
memo-clear!
.memo-*
APIs(cache-type function <base><:cache-type/threshold int>)
Copyright (c) Rich Hickey and Michael Fogus, 2012, 2013. All rights reserved. The use and distribution terms for this software are covered by the Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) which can be found in the file epl-v10.html at the root of this distribution. By using this software in any fashion, you are agreeing to be bound bythe terms of this license. You must not remove this notice, or any other, from this software.