core.memoize is a 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 function but, unlike the built-in memoize function, ensures that in the case of concurrent calls with the same arguments, the memoized function is only invoked once; in addition memo can use metadata from the memoized function to ignore certain arguments for the purpose of creating the cache key, e.g., allowing you to memoize clojure.java.jdbc functions where the first argument includes a (mutable) JDBC Connection object by specifying :clojure.core.memoize/args-fn rest in the metadataFunctions for manipulating the memoization cache of core.memoize backed functions
This project follows the version scheme MAJOR.MINOR.COMMITS where MAJOR and MINOR provide some relative indication of the size of the change, but do not follow semantic versioning. In general, all changes endeavor to be non-breaking (by moving to new names rather than by breaking existing names). COMMITS is an ever-increasing counter of commits since the beginning of this repository.
Latest stable release: 1.0.257
CLI/deps.edn dependency information:
org.clojure/core.memoize {:mvn/version "1.0.257"}
Leiningen dependency information:
[org.clojure/core.memoize "1.0.257"]
Maven dependency information:
<dependency>
  <groupId>org.clojure</groupId>
  <artifactId>core.memoize</artifactId>
  <version>1.0.257</version>
</dependency>
    (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.
ttl docstring (j-mckitrick).IPending for RetryingDelay for folks trying to do low-level availability tests on long-running memoized functions.core.cache to 1.0.225clojure.core/memoize and clojure.core.memoize/memo functions CMEMOIZE-25.core.cache to 1.0.217.core.cache dependency version from 0.8.2 to 1.0.207.memo-reset! and deprecates 2-arity version of memo-swap!; adds 3+-arity version of memo-swap! to behave more like a swap! operation on the underlying cachecore.cache dependency version from 0.7.2 to 0.8.2.memoizer as a more convenient way to build custom cached functions that may provide a seed hash map of arguments to return values. build-memoizer should be considered deprecated at this point.seed function on PluggableMemoization now makes elements derefable (this case was missed when CMEMOIZE-18 was fixed)memo-swap! (discovered by Teemu Kaukoranta):clojure.core.memoize/args-fn metadata support for memoizing functions which have one or more arguments that should not contribute to the cache key for callslazy-snapshot functionderef-able to match documentation and comply with core.memoize's world viewmemo-clear!.memo-* APIs(cache-type function <base><:cache-type/threshold int>)Copyright (c) Rich Hickey and Michael Fogus, 2023. All rights reserved. The use and distribution terms for this software are covered by the Eclipse Public License 1.0 (https://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.
Can you improve this documentation? These fine people already did:
Sean Corfield, fogus, Alex Miller, Fogus, Nicola Mometto & Max PenetEdit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs | 
| ← | Move to previous article | 
| → | Move to next article | 
| Ctrl+/ | Jump to the search field |