Liking cljdoc? Tell your friends :D

cljs.cache.wrapped

A higher level way to use clojure.core.cache that assumes the immutable cache is wrapped in an atom.

The API is (almost) the same as clojure.core.cache -- including the factory functions -- but instead of accepting immutable caches, the functions here accept atoms containing those caches. The factory functions return new atoms containing the newly created cache.

In addition, lookup-or-miss provides a safe, atomic way to retrieve a value from a cache or compute it if it is missing, without risking a cache stampede.

A higher level way to use clojure.core.cache that assumes the immutable
cache is wrapped in an atom.

The API is (almost) the same as clojure.core.cache -- including the factory
functions -- but instead of accepting immutable caches, the functions
here accept atoms containing those caches. The factory functions return
new atoms containing the newly created cache.

In addition, lookup-or-miss provides a safe, atomic way to retrieve a
value from a cache or compute it if it is missing, without risking a
cache stampede.
raw docstring

basic-cache-factorycljs

(basic-cache-factory base)

Returns a pluggable basic cache initialized to base

Returns a pluggable basic cache initialized to `base`
raw docstring

evictcljs

(evict cache-atom e)

Removes an entry from the cache.

Returns the updated cache from the atom.

Removes an entry from the cache.

Returns the updated cache from the atom.
raw docstring

has?cljs

(has? cache-atom e)

Checks if the cache contains a value associated with e.

Reads from the current version of the atom.

Checks if the cache contains a value associated with `e`.

Reads from the current version of the atom.
raw docstring

hitcljs

(hit cache-atom e)

Is meant to be called if the cache is determined to contain a value associated with e.

Returns the updated cache from the atom. Provided for completeness.

Is meant to be called if the cache is determined to contain a value
associated with `e`.

Returns the updated cache from the atom. Provided for completeness.
raw docstring

lookupcljs

(lookup cache-atom e)
(lookup cache-atom e not-found)

Retrieve the value associated with e if it exists, else nil in the 2-arg case. Retrieve the value associated with e if it exists, else not-found in the 3-arg case.

Reads from the current version of the atom.

Retrieve the value associated with `e` if it exists, else `nil` in
the 2-arg case.  Retrieve the value associated with `e` if it exists,
else `not-found` in the 3-arg case.

Reads from the current version of the atom.
raw docstring

lookup-or-misscljs

(lookup-or-miss cache-atom e value-fn)
(lookup-or-miss cache-atom e wrap-fn value-fn)

Retrieve the value associated with e if it exists, else compute the value (using value-fn, and optionally wrap-fn), update the cache for e and then perform the lookup again.

value-fn (and wrap-fn) will only be called (at most) once even in the case of retries, so there is no risk of cache stampede.

Since lookup can cause invalidation in some caches (such as TTL), we trap that case and retry (a maximum of ten times).

Retrieve the value associated with `e` if it exists, else compute the
value (using value-fn, and optionally wrap-fn), update the cache for `e`
and then perform the lookup again.

value-fn (and wrap-fn) will only be called (at most) once even in the
case of retries, so there is no risk of cache stampede.

Since lookup can cause invalidation in some caches (such as TTL), we
trap that case and retry (a maximum of ten times).
raw docstring

lru-cache-factorycljs

(lru-cache-factory base & {threshold :threshold :or {threshold 32}})

Returns an LRU cache with the cache and usage-table initialized to base -- each entry is initialized with the same usage value.

This function takes an optional :threshold argument that defines the maximum number of elements in the cache before the LRU semantics apply (default is 32).

Returns an LRU cache with the cache and usage-table initialized to `base` --
each entry is initialized with the same usage value.

This function takes an optional `:threshold` argument that defines the maximum number
of elements in the cache before the LRU semantics apply (default is 32).
raw docstring

misscljs

(miss cache-atom e ret)

Is meant to be called if the cache is determined to not contain a value associated with e.

Returns the updated cache from the atom. Provided for completeness.

Is meant to be called if the cache is determined to **not** contain a
value associated with `e`.

Returns the updated cache from the atom. Provided for completeness.
raw docstring

seedcljs

(seed cache-atom base)

Is used to signal that the cache should be created with a seed. The contract is that said cache should return an instance of its own type.

Returns the updated cache from the atom. Provided for completeness.

Is used to signal that the cache should be created with a seed.
The contract is that said cache should return an instance of its
own type.

Returns the updated cache from the atom. Provided for completeness.
raw docstring

throughcljs

(through cache-atom item)
(through value-fn cache-atom item)
(through wrap-fn value-fn cache-atom item)

The basic hit/miss logic for the cache system. Expects a wrap function and value function. The wrap function takes the value function and the item in question and is expected to run the value function with the item whenever a cache miss occurs. The intent is to hide any cache-specific cells from leaking into the cache logic itelf.

The basic hit/miss logic for the cache system.  Expects a wrap function and
value function.  The wrap function takes the value function and the item in question
and is expected to run the value function with the item whenever a cache
miss occurs.  The intent is to hide any cache-specific cells from leaking
into the cache logic itelf.
raw docstring

through-cachecljs

(through-cache cache-atom item)
(through-cache cache-atom item value-fn)
(through-cache cache-atom item wrap-fn value-fn)

The basic hit/miss logic for the cache system. Like through but always has the cache argument in the first position.

The basic hit/miss logic for the cache system.  Like through but always has
the cache argument in the first position.
raw docstring

ttl-cache-factorycljs

(ttl-cache-factory base & {ttl :ttl :or {ttl 2000}})

Returns a TTL cache with the cache and expiration-table initialized to base -- each with the same time-to-live.

This function also allows an optional :ttl argument that defines the default time in milliseconds that entries are allowed to reside in the cache.

Returns a TTL cache with the cache and expiration-table initialized to `base` --
each with the same time-to-live.

This function also allows an optional `:ttl` argument that defines the default
time in milliseconds that entries are allowed to reside in the cache.
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close