Subject: [bug#53765] [PATCH v2 05/18] gnu: Add clojure-core-memoize.

From: Reily Siegel <[email-masked]>
Date: Wed, 16 Mar 2022 13:43:55 +0100

* gnu/packages/clojure.scm (clojure-core-memoize): New variable.
---
 gnu/packages/clojure.scm | 51 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/gnu/packages/clojure.scm b/gnu/packages/clojure.scm
index 37cea74c95..d6c8218f93 100644
--- a/gnu/packages/clojure.scm
+++ b/gnu/packages/clojure.scm
@@ -341,6 +341,57 @@ (define-public clojure-core-match
       (home-page "https://github.com/clojure/core.match")
       (license license:epl1.0))))
 
+(define-public clojure-core-memoize
+  (package
+    (name "clojure-core-memoize")
+    (version "1.0.253")
+    (home-page "https://github.com/clojure/core.memoize")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url home-page)
+                    (commit (string-append "v" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "1qky54v114sh3xn0lffwy7xx3wnnayk07fr2nvhd4lih84sv6rdz"))))
+    (build-system clojure-build-system)
+    (arguments
+     '(#:source-dirs '("src/main/clojure")
+       #:test-dirs '("src/test/clojure")
+       #:doc-dirs '("docs")
+       ;; Tests fail when AOT'd.
+       #:aot-exclude '(#:all)))
+    (propagated-inputs (list clojure-core-cache))
+    (synopsis "Manipulable, pluggable, memoization framework for Clojure")
+    (description "@code{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:
+
+First-in-first-out (clojure.core.memoize/fifo)
+
+Least-recently-used (clojure.core.memoize/lru)
+
+Least-used (clojure.core.memoize/lu)
+
+Time-to-live (clojure.core.memoize/ttl)
+
+Naive cache (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 metadata")
+    (license license:epl1.0)))
+
 (define-public clojure-data-codec
   (package
     (name "clojure-data-codec")
-- 
2.34.0

-- 
Reily Siegel