Skip to main content
interface KvMemoizeOptions
import { type KvMemoizeOptions } from "https://deno.land/x/kv_memoize@v0.1.0/mod.ts";

Options for kvMemoize.

Properties

optional
expireIn: ((
this: void,
result: R,
...args: A,
) => number | undefined) | number | undefined

The time in milliseconds until the cached result expires.

optional
shouldRecalculate: ((
this: void,
result: NonNullable<R>,
...args: A,
) => boolean) | undefined

Whether to recalculate the result if it was already cached.

Runs whenever the result is retrieved from the cache.

A nullish result will always be recalculated.

Defaults to never recalculating the result.

optional
shouldCache: ((
this: void,
result: NonNullable<R>,
...args: A,
) => boolean) | undefined

Whether to cache the result after computing it.

Runs whenever a new result is computed.

A nullish result will never be cached.

Defaults to always caching the result.

optional
kv: { get: (
this: void,
db: Deno.Kv,
key: [...K, ...A],
) => Promise<R | undefined>; set: (
this: void,
db: Deno.Kv,
key: [...K, ...A],
value: R,
options: { expireIn?: number; },
) => Promise<void>; }

Override the default Deno.Kv set and get methods.