@eryx/caching Module
Small in-memory cache primitives.
- bounded key/value caches
- TTL-based expiration
- memoization built on top of those caches
Higher-level policy such as HTTP cache semantics should live in the consumer modules rather than here.
Summary
Functions
Cache:clear<K, V>() → ()
caching.memoize<K, V, T...>(fn: ((T...) → V), options: { maxEntries: number?, ttl: number?, touchOnGet: boolean?, clock: Clock?, onEvict: (((key: K, value: V, reason: EvictReason) → ()))?, cache: Cache<K, V>?, keyFn: (((T...) → K))? }?) → ((T...) → V)
API Reference
Functions
Cache:get
Cache:set
Cache:has
Cache:delete
Cache:clear
Cache:clear<K, V>() → ()
Cache:size
Cache:prune
caching.lru
caching.ttl
caching.memoize
Types
EvictReason
CacheOptions<K, V>
type CacheOptions<K, V> = {
maxEntries: number?,
ttl: number?,
touchOnGet: boolean?,
clock: Clock?,
onEvict: (((key: K, value: V, reason: EvictReason) → ()))?
}
MemoizeOptions<K, V, T...>
type MemoizeOptions<K, V, T...> = {
maxEntries: number?,
ttl: number?,
touchOnGet: boolean?,
clock: Clock?,
onEvict: (((key: K, value: V, reason: EvictReason) → ()))?,
cache: Cache<K, V>?,
keyFn: (((T...) → K))?
}
keyFn: (((T...) → K))?