Memoization library.
Memoization library.
(active-cache f)
Return Cache instance from the function, if present.
Return Cache instance from the function, if present.
(as-map f)
Return a map representation of the memoized entries on this function.
Return a map representation of the memoized entries on this function.
(bind fn-or-var mount-conf cache)
Bind the cache to a function or a var. If a var is specified, then var root binding is modified.
The mount-conf is a configuration options for mount point.
It can be a map with options, a vector of tags, or one tag.
Supported options are:
Bind the cache to a function or a var. If a var is specified, then var root binding is modified. The mount-conf is a configuration options for mount point. It can be a map with options, a vector of tags, or one tag. Supported options are: - memento.core/key-fn - memento.core/ret-fn - memento.core/tags - memento.core/seed
(consulting cache upstream)
Creates a configuration for a consulting tiered cache. Both parameters are either a conf map or a cache.
Entry is fetched from cache, if not found, the upstream is asked for entry if present (but not to make one in the upstream).
After the operation, the entry is in local cache, upstream is unchanged.
Useful when you want to consult a long term upstream cache for existing entries, but you don't want any entries being created for the short term cache to be pushed upstream.
Invalidation operations also affect upstream. Other operations only affect local cache.
Creates a configuration for a consulting tiered cache. Both parameters are either a conf map or a cache. Entry is fetched from cache, if not found, the upstream is asked for entry if present (but not to make one in the upstream). After the operation, the entry is in local cache, upstream is unchanged. Useful when you want to consult a long term upstream cache for existing entries, but you don't want any entries being created for the short term cache to be pushed upstream. Invalidation operations also affect upstream. Other operations only affect local cache.
(create conf)
Create a cache.
A conf is a map of cache settings, see memento.config namespace for names of settings.
Create a cache. A conf is a map of cache settings, see memento.config namespace for names of settings.
(daisy cache upstream)
Creates a configuration for a daisy chained cache. Cache parameter is a conf map or a cache.
Entry is returned from cache IF PRESENT, otherwise upstream is hit. The returned value is NOT added to cache.
After the operation the entry is either in local or upstream cache.
Useful when you don't want entries from upstream accumulating in local cache, and you're feeding the local cache via some other means:
Invalidation operations also affect upstream. Other operations only affect local cache.
Creates a configuration for a daisy chained cache. Cache parameter is a conf map or a cache. Entry is returned from cache IF PRESENT, otherwise upstream is hit. The returned value is NOT added to cache. After the operation the entry is either in local or upstream cache. Useful when you don't want entries from upstream accumulating in local cache, and you're feeding the local cache via some other means: - a preloaded fixed cache - manually adding entries Invalidation operations also affect upstream. Other operations only affect local cache.
(do-not-cache v)
Wrap a function result value in a wrapper that tells the Cache not to cache this particular value.
Wrap a function result value in a wrapper that tells the Cache not to cache this particular value.
(evt-cache-add evt-type ->entries)
(evt-cache-add evt-fn evt-type ->entries)
Convenience function. It creates or wraps event handler fn, with an implementation which expects an event to be a vector of [event-type payload], it checks for matching event type and inserts the result of (->entries payload) into the cache.
Convenience function. It creates or wraps event handler fn, with an implementation which expects an event to be a vector of [event-type payload], it checks for matching event type and inserts the result of (->entries payload) into the cache.
(fire-event! f-or-tag evt)
Fire an event payload to the single cached function or all tagged functions, if tag is provided.
Fire an event payload to the single cached function or all tagged functions, if tag is provided.
(if-cached bindings then)
(if-cached bindings then else)
Like if-let, but then clause is executed if the call in the binding is cached, with the binding symbol being bound to the cached value.
This assumes that the top form in bindings is a call of cached function, generating an error otherwise.
e.g. (if-cached [my-val (my-cached-fn arg1)] ...)
Like if-let, but then clause is executed if the call in the binding is cached, with the binding symbol being bound to the cached value. This assumes that the top form in bindings is a call of cached function, generating an error otherwise. e.g. (if-cached [my-val (my-cached-fn arg1)] ...)
(memo fn-or-var conf)
(memo fn-or-var mount-conf cache-conf)
Combines cache create and bind operations from this namespace.
If conf is provided, it is used as mount-conf in bind operation, but with any extra map keys going into cache create configuration.
Combines cache create and bind operations from this namespace. If conf is provided, it is used as mount-conf in bind operation, but with any extra map keys going into cache create configuration.
(memo-add! f m)
Add map's entries to the cache. The keys are argument-lists.
Returns f.
Add map's entries to the cache. The keys are argument-lists. Returns f.
(memo-clear! f)
(memo-clear! f & fargs)
Invalidate one entry (f with arglist) on memoized function f, or invalidate all entries for memoized function. Returns f.
Invalidate one entry (f with arglist) on memoized function f, or invalidate all entries for memoized function. Returns f.
(memo-clear-cache! cache)
Invalidate all entries in Cache. Returns cache.
Invalidate all entries in Cache. Returns cache.
(memo-clear-tag! tag id)
Invalidate all entries that have the specified tag + id metadata. ID can be anything.
Invalidate all entries that have the specified tag + id metadata. ID can be anything.
(memo-unwrap f)
Takes a function and returns an uncached function.
Takes a function and returns an uncached function.
(memoized? f)
Returns true if function is memoized.
Returns true if function is memoized.
(mounts-by-tag tag)
Returns a sequence of MountPoint instances used by memoized functions which are tagged by this tag.
Returns a sequence of MountPoint instances used by memoized functions which are tagged by this tag.
(tags f)
Return tags of the memoized function.
Return tags of the memoized function.
(tiered cache upstream)
Creates a configuration for a tiered cache. Both parameters are either a conf map or a cache.
Entry is fetched from cache, delegating to upstream is not found. After the operation the entry is in both caches.
Useful when upstream is a big cache that outside the JVM, but it's not that inexpensive, so you want a local smaller cache in front of it.
Invalidation operations also affect upstream. Other operations only affect local cache.
Creates a configuration for a tiered cache. Both parameters are either a conf map or a cache. Entry is fetched from cache, delegating to upstream is not found. After the operation the entry is in both caches. Useful when upstream is a big cache that outside the JVM, but it's not that inexpensive, so you want a local smaller cache in front of it. Invalidation operations also affect upstream. Other operations only affect local cache.
(update-tag-caches! tag cache-fn)
For each memoized function with the specified tag, set the Cache used by the fn to (cache-fn current-cache).
Cache update function is ran on each memoized function (mount point), so if one cache is backing multiple functions, the cache update function is called multiple timed on it. If you want to run cache-fn one each Cache instance only once, I recommend wrapping it in clojure.core/memoize.
If caches are thread-bound to a different value with with-caches, then those bindings are modified instead of root bindings.
For each memoized function with the specified tag, set the Cache used by the fn to (cache-fn current-cache). Cache update function is ran on each memoized function (mount point), so if one cache is backing multiple functions, the cache update function is called multiple timed on it. If you want to run cache-fn one each Cache instance only once, I recommend wrapping it in clojure.core/memoize. If caches are thread-bound to a different value with with-caches, then those bindings are modified instead of root bindings.
(with-caches tag cache-fn & body)
Within the block, each memoized function with the specified tag has its cache update by cache-fn.
The values are bound within the block as a thread local binding. Cache update function is ran on each memoized function (mount point), so if one cache is backing multiple functions, the cache update function is called multiple timed on it. If you want to run cache-fn one each Cache instance only once, I recommend wrapping it in clojure.core/memoize.
Within the block, each memoized function with the specified tag has its cache update by cache-fn. The values are bound within the block as a thread local binding. Cache update function is ran on each memoized function (mount point), so if one cache is backing multiple functions, the cache update function is called multiple timed on it. If you want to run cache-fn one each Cache instance only once, I recommend wrapping it in clojure.core/memoize.
(with-tag-id v tag id)
Wrap a function result value in a wrapper that has the given additional tag + ID information. You can add multiple IDs for same tag.
This information is later used by memo-clear-tag!.
Wrap a function result value in a wrapper that has the given additional tag + ID information. You can add multiple IDs for same tag. This information is later used by memo-clear-tag!.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close