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

x/frugal/packages/core/Cache.ts>Cache

A frugal web framework
Go to Latest
class Cache
import { Cache } from "https://deno.land/x/frugal@0.2.1/packages/core/Cache.ts";

Base Cache class

Constructors

new
Cache(serialized: SerializedCache, config?: CacheConfig)

Type Parameters

optional
VALUE = unknown

Methods

get<V = VALUE>(key: string): V | undefined

Return the value associated to the given key (in hot data first, then cold)

had(key: string)

Returns true if the key is present from the previous run (cold data)

has(key: string)

Returns true if the key is present from the current run (hot data)

memoize<V = VALUE>(unnamed 0: MemoizeConfig<V>): Promise<V>

For a given key, call the producer function if the key is not present (in hot or cold data).

If the key is present in cold data, call the otherwise function, and propagate the key and its value in hot data.

It the key is present in hot data, call the otherwise function

propagate(key: string)

If the key is cold, set it to hot data

set<V = VALUE>(key: string, value: V)

Set the value associated to the key in hot data

Static Methods

unserialize(serialized?: SerializedCache, config?: CacheConfig)