Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/velo/src/cache/capabilities/loading_capability.ts>LoadingCapability

A high-performance caching library for Deno. Supports LRU, LFU, ARC, and TinyLFU.
Latest
class LoadingCapability
implements LoadingCache<K, V>
extends CapabilityWrapper<K, V>
import { LoadingCapability } from "https://deno.land/x/velo@1.0.0/src/cache/capabilities/loading_capability.ts";

Adds loading functionality to a cache. The loader function is called when a cache miss occurs in get. Then the generated value is stored in the cache with set and returned. The refresh method can be used to refresh the value of a key, via the loader function.

Constructors

new
LoadingCapability(inner: Cache<K, V> & CacheInternal<K, V>, loader: LoaderFunction<K, V>)

Properties

private
loader: LoaderFunction<K, V>

Methods

get(key: K): V
refresh(key: K)

Runs the loader function for a given key and sets the generated value