• Stars
    star
    263
  • Rank 155,624 (Top 4 %)
  • Language
    Clojure
  • License
    Eclipse Public Li...
  • Created about 13 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A manipulable, pluggable, memoization framework for Clojure

clojure.core.memoize

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
  • Functions for manipulating the memoization cache of core.memoize backed functions

Releases and Dependency Information

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>

Example Usage

    (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.

Developer Information

Change Log

  • Release 1.0.next in progress
    • Fixes CMEMOIZE-30 - typo in ttl docstring (j-mckitrick).
  • Release 1.0.257 on 2022.02.11
    • Implement IPending for RetryingDelay for folks trying to do low-level availability tests on long-running memoized functions.
  • Release 1.0.253 on 2021.12.06
    • Update core.cache to 1.0.225
  • Release 1.0.250 on 2021.08.02
    • Clarify differences between clojure.core/memoize and clojure.core.memoize/memo functions CMEMOIZE-25.
    • Update core.cache to 1.0.217.
  • Release 1.0.236 on 2020.04.13
    • Switch to 1.0.x versioning CMEMOIZE-29.
    • Update core.cache dependency version from 0.8.2 to 1.0.207.
    • Fixes CMEMOIZE-9 - adds 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 cache
  • Release 0.8.2 on 2019.11.01 (to match core.cache again)
    • Update core.cache dependency version from 0.7.2 to 0.8.2.
    • Fixes CMEMOIZE-28 - provides 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.
    • Fixes CMEMOIZE-27 - the seed function on PluggableMemoization now makes elements derefable (this case was missed when CMEMOIZE-18 was fixed)
  • Release 0.7.2 on 2019.06.13
    • Fixes CMEMOIZE-26 - zero-arity function cache could not be replaced by memo-swap! (discovered by Teemu Kaukoranta)
    • Updated core.cache dependency version from 0.7.1 to 0.7.2
    • Updated test matrix locally to include Clojure 1.10.1, 1.11 master
  • Release 0.7.1 on 2018.03.02
    • Fixes CMEMOIZE-15 - edge case where cache miss/lookup cross an eviction boundary (Ryan Fowler/Colin Jones)
    • Updated core.cache dependency version from 0.7.0 to 0.7.1 (for TTLCacheQ bug fix)
  • Release 0.7.0 on 2018.03.01
    • Fixes CMEMOIZE-22 - add :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 calls
    • Fixes CMEMOIZE-20 - add lazy-snapshot function
    • Fixes CMEMOIZE-18 - automatically makes seed map values deref-able to match documentation and comply with core.memoize's world view
    • Cleanup/improve/fix tests
    • Add multi-version testing locally via Leiningen
    • Jump to 0.7.0 to match core.cache since these two libraries are so closely in sync
  • Release 0.5.9 on 2016.03.28
    • Updated core.cache dependency version from 0.6.4 to 0.6.5
  • Release 0.5.8 on 2015.11.06
  • Release 0.5.7 on 2015.01.12
  • Release 0.5.6 on 2013.06.28
    • Added optional args to memo-clear!.
    • Widened contract on factory functions to accept any callable.
  • Release 0.5.5 on 2013.06.14
    • Deprecated memo-* APIs
    • Adds new API of form (cache-type function <base><:cache-type/threshold int>)
  • Release 0.5.4 on 2013.06.03
  • Release 0.5.3 on 2013.03.18
    • Works with core.cache v0.6.3
  • Release 0.5.2 on 2012.07.13
    • Works with core.cache v0.6.1
  • Release 0.5.1 on 2011.12.13
    • Removed SoftCache memoization
  • Release 0.5.0 on 2011.12.13
    • Rolled in basis of Unk

Copyright and License

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.

More Repositories

1

clojure

The Clojure programming language
Java
10,334
star
2

clojurescript

Clojure to JS compiler
Clojure
9,191
star
3

core.async

Facilities for async programming and communication in Clojure
Clojure
1,935
star
4

clojure-clr

A port of Clojure to the CLR, part of the Clojure project
C#
1,541
star
5

core.logic

A logic programming library for Clojure & ClojureScript
Clojure
1,434
star
6

core.typed

An optional type system for Clojure
Clojure
1,285
star
7

core.match

An optimized pattern matching library for Clojure
Clojure
1,180
star
8

test.check

QuickCheck for Clojure
Clojure
1,112
star
9

java.jdbc

JDBC from Clojure (formerly clojure.contrib.sql)
Clojure
714
star
10

tools.cli

Command-line processing
Clojure
711
star
11

tools.nrepl

A Clojure network REPL that provides a server and client, along with some common APIs of use to IDEs and other tools that may need to evaluate Clojure code in remote environments.
Clojure
661
star
12

tools.namespace

Tools for managing namespaces in Clojure
Clojure
596
star
13

data.json

JSON in Clojure
Clojure
536
star
14

algo.monads

Macros for defining monads, and definition of the most common monads
Clojure
444
star
15

core.cache

A caching library for Clojure implementing various cache strategies
Clojure
442
star
16

tools.deps.alpha

A functional API for transitive dependency graph expansion and the creation of classpaths
Clojure
435
star
17

tools.logging

Clojure logging API
Clojure
382
star
18

tools.trace

1.3 update of clojure.contrib.trace
Clojure
354
star
19

math.combinatorics

Efficient, functional algorithms for generating lazy sequences for common combinatorial functions
Clojure
343
star
20

spec-alpha2

Clojure library to describe the structure of data and functions
Clojure
297
star
21

data.csv

CSV reader/writer to/from Clojure data structures
Clojure
270
star
22

tools.analyzer

An analyzer for Clojure code, written in Clojure and producing AST in EDN
Clojure
257
star
23

clojure-site

clojure.org site
HTML
249
star
24

data.xml

Clojure
220
star
25

data.finger-tree

Finger Tree data structure
Clojure
213
star
26

spec.alpha

Clojure library to describe the structure of data and functions
Clojure
212
star
27

tools.reader

Clojure reader in Clojure
Clojure
203
star
28

tools.build

Clojure builds as Clojure programs
Clojure
200
star
29

core.rrb-vector

RRB-Trees in Clojure
Clojure
191
star
30

data.priority-map

Clojure priority map data structure
Clojure
186
star
31

math.numeric-tower

Math functions that deal intelligently with the various types in Clojure's numeric tower
Clojure
175
star
32

test.generative

Generative test runner
Clojure
161
star
33

core.unify

Unification library
Clojure
137
star
34

core.contracts

Contracts programming
Clojure
127
star
35

data.fressian

Read and write Fressian data from Clojure
Clojure
127
star
36

data.avl

Persistent sorted maps and sets with log-time rank queries
Clojure
125
star
37

data.int-map

A map optimized for integer keys
Java
124
star
38

core.incubator

Proving ground for proposed new core fns
Clojure
116
star
39

java.data

Functions for recursively converting Java beans to Clojure and vice versa
Clojure
114
star
40

tools.analyzer.jvm

Additional jvm-specific passes for tools.analyzer
Clojure
113
star
41

tools.macro

Utilities for macro writers
Clojure
113
star
42

clojurescript-site

website for ClojureScript
Shell
106
star
43

tools.deps.graph

Dependency graphs for deps.edn projects
Clojure
106
star
44

java.jmx

Produce and consume JMX beans from Clojure
Clojure
94
star
45

algo.generic

Generic versions of commonly used functions, implemented as multimethods that can be implemented for any data type
Clojure
92
star
46

tools.emitter.jvm

A JVM bytecode generator for ASTs compatible with tools.analyzer(.jvm)
Clojure
86
star
47

data.generators

Random data generators
Clojure
85
star
48

data.zip

Utilities for clojure.zip
Clojure
83
star
49

brew-install

Clojure CLI installer
Shell
81
star
50

data.codec

Native codec implementations
Clojure
74
star
51

tools.gitlibs

API for retrieving, caching, and programatically accessing git libraries
Clojure
62
star
52

java.classpath

Examine the Java classpath from Clojure programs
Clojure
59
star
53

jvm.tools.analyzer

Clojure
53
star
54

core.specs.alpha

specs to describe Clojure core macros and functions
Clojure
47
star
55

tools.tools

Clojure CLI tool for managing Clojure CLI tools
Clojure
42
star
56

homebrew-tools

Clojure homebrew tap providing Clojure formulae
Ruby
41
star
57

data.alpha.replicant-server

A Clojure library providing remote implementations of the Clojure data structures and a remote REPL server.
Clojure
37
star
58

test.benchmark

Benchmark and Regression Suite for Clojure
Roff
37
star
59

clr.tools.nrepl

Clojure
25
star
60

build.ci

Support scripts for continuous integration
Clojure
23
star
61

tools.analyzer.js

Provides js-specific passes for tools.analyzer
Clojure
21
star
62

algo.graph

Basic graph theory algorithms
Clojure
16
star
63

clojure-install

Java
16
star
64

data.alpha.replicant-client

A Clojure library providing client-side implementations of Clojure datastructures served by replicant-server.
Clojure
13
star
65

clojure.github.com

Documentation repos
HTML
8
star
66

build.poms

Parent POMs
8
star
67

core.typed.analyzer.jvm

Clojure
7
star
68

clr.tools.namespace

Clojure
7
star
69

core.typed.runtime.jvm

Clojure
7
star
70

clr.data.json

JSON in Clojure on the CLR
Clojure
6
star
71

clr.tools.reader

Clojure
5
star
72

clr.test.generative

Clojure
5
star
73

clojure-api-doc

Clojure API doc build
Clojure
5
star
74

contrib-api-doc

Clojure contrib API doc build
Clojure
5
star
75

core.typed.annotator.jvm

Clojure
5
star
76

core.typed.checker.jvm

Clojure
4
star
77

core.typed.checker.js

Clojure
4
star
78

io.incubator

Proving ground for proposed new io fns
4
star
79

clr.data.generators

Random data generators for Clojure on the CLR
Clojure
4
star
80

clr.core.async

Port of Clojure core.async to the CLR
Clojure
3
star
81

clr.spec.alpha

spec on the CLR
Clojure
3
star
82

clr.tools.analyzer

Clojure
3
star
83

test.regression

Regression tests for Clojure
Clojure
3
star
84

tools.deps.cli

Deps functions
Clojure
2
star
85

clr.core.specs.alpha

core specs on CLR
HTML
2
star
86

java.internal.invoke

2
star
87

clr.tools.gitlibs

An API for retrieving, caching, and programatically accessing git libraries
HTML
2
star
88

clr.core.logic

Clojure
2
star
89

clr.tools.trace

1
star
90

clr.core.cli

Clojure
1
star
91

clr.data.priority-map

ClojureCLR port of data.priority-map
Clojure
1
star
92

cljs.tools.closure

ClojureScript build of Google Closure
Shell
1
star
93

tools.analyzer.clr

additional clr-specific passes for tools.analyzer
Clojure
1
star
94

clr.test.check

Clojure
1
star
95

clr.core.cache

ClojureCLR port of core.cache
Clojure
1
star
96

clr.tools.logging

1
star
97

build.test

Dummy project for testing contrib build and deploy
Clojure
1
star
98

clr.core.memoize

ClojureCLR port of core.memoize
Clojure
1
star