import { Velo } from "https://deno.land/x/velo@1.0.0/mod.ts";
Builder class for Cache and LoadingCache. Allows to add optional functionality to a cache. The following options are available:
- size-based eviction (capacity)
- multiple cache strategies (policy, lru, lfu, arc, sc, tinyLfu)
- automated loading of cache values (build(fn: LoaderFunction))
- time-based expiration of entries (ttl)
- listener for cache removals (removalListener)
- eventEmitter for cache events (events)
- collecting cache hit and miss statistics (stats)
All listed features are optional. By default the cache has no functionality.
Methods
private
requireExpr(expression: boolean, message?: string)Builds a Cache or LoadingCache instance based on the options specified with this builder.
removalListener(listener: RemoveListener<K, V>)
Registers a RemoveListener function. For cache removals.
ttl(timeout: number, options?: ExpireOptions)
Specifies the time-to-live for cache entries. Takes optional ExpireOptions to specify when to refresh the TTL. By default it is never refreshed.