std.lib.memoize

*registry*

dynamic

deregister-memoize

added in 3.0

(deregister-memoize mem)(deregister-memoize mem var registry)

deregisters the memoize function

(deregister-memoize -inc-)

invoke-intern-memoize

added in 3.0

(invoke-intern-memoize _ name {:keys [function cache], :as config} body)

creates a memoize form template for definvoke

(invoke-intern-memoize :memoize ’hello {} ’(x x))

memoize

added in 3.0

(memoize function cache var)(memoize function cache var registry status)

caches the result of a function (ns-unmap ns ’+-inc-) (ns-unmap ns ‘-inc-) (def +-inc- (atom {})) (declare -inc-) (def -inc- (memoize inc +-inc- #’-inc-))

(-inc- 1) => 2 (-inc- 2) => 3

memoize:clear

added in 3.0

(memoize:clear mem)

clears all results

(memoize:clear -inc-) => ’{(2) 3}

memoize:disable

added in 3.0

(memoize:disable mem)

disables the usage of the cache

(memoize:disable -inc-) => :disabled

memoize:disabled?

added in 3.0

(memoize:disabled? mem)

checks if the memoized function is disabled

(memoize:disabled? -inc-) => true

memoize:enable

added in 3.0

(memoize:enable mem)

enables the usage of the cache

(memoize:enable -inc-) => :enabled

memoize:enabled?

added in 3.0

(memoize:enabled? mem)

checks if the memoized function is disabled

(memoize:enabled? -inc-) => true

memoize:info

added in 3.0

(memoize:info mem)

formats the memoize object

(def +-plus- (atom {})) (declare -plus-) (def -plus- (memoize + +-plus- #’-plus-)) (memoize:info -plus-) => (contains {:status :enabled, :registered false, :items number?}) ;; {:fn +, :cache #atom {(1 1) 2}}

memoize:invoke

added in 3.0

(memoize:invoke mem & args)

invokes the function with arguments

(memoize:invoke -plus- 1 2 3) => 6

memoize:remove

added in 3.0

(memoize:remove mem & args)

removes a cached result

(memoize:remove -inc- 1) => 2

memoize:status

added in 3.0

(memoize:status mem)

returns the status of the object

(memoize:status -inc-) => :enabled

register-memoize

added in 3.0

(register-memoize mem)(register-memoize mem var registry)

registers the memoize function

(register-memoize -inc-)

registered-memoize?

added in 3.0

(registered-memoize? mem)

checks if a memoize function is registered

(registered-memoize? -mem-) => false

registered-memoizes

added in 3.0

(registered-memoizes)(registered-memoizes status)(registered-memoizes status registry)

lists all registered memoizes

(registered-memoizes)