Skip to main content
Home

@std/cache@0.2.0
Built and signed on GitHub Actions

UNSTABLE: Cache utilities

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
2 months ago (0.2.0)
type alias MemoizeOptions
Unstable

Options for memoize.

Type Parameters

Fn extends (...args: never[]) => unknown

The type of the function to memoize.

Key

The type of the cache key.

Cache extends MemoizationCache<Key, MemoizationCacheResult<ReturnType<Fn>>>

The type of the cache.

Properties

optional
cache: Cache

Provide a custom cache for getting previous results. By default, a new Map object is instantiated upon memoization and used as a cache, with no limit on the number of results to be cached.

Alternatively, you can supply a LruCache with a specified max size to limit memory usage.

optional
getKey: (
this: ThisParameterType<Fn>,
...args: Parameters<Fn>,
) => Key

Function to get a unique cache key from the function's arguments. By default, a composite key is created from all the arguments plus the this value, using reference equality to check for equivalence.

optional
errorIsCacheable: (err: unknown) => boolean = () => false

Callback to determine if an error or other thrown value is cacheable.

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@std/cache

Import symbol

import { type MemoizeOptions } from "@std/cache/memoize";
or

Import directly with a jsr specifier

import { type MemoizeOptions } from "jsr:@std/cache/memoize";

Add Package

pnpm i jsr:@std/cache
or (using pnpm 10.8 or older)
pnpm dlx jsr add @std/cache

Import symbol

import { type MemoizeOptions } from "@std/cache/memoize";

Add Package

yarn add jsr:@std/cache
or (using Yarn 4.8 or older)
yarn dlx jsr add @std/cache

Import symbol

import { type MemoizeOptions } from "@std/cache/memoize";

Add Package

vlt install jsr:@std/cache

Import symbol

import { type MemoizeOptions } from "@std/cache/memoize";

Add Package

npx jsr add @std/cache

Import symbol

import { type MemoizeOptions } from "@std/cache/memoize";

Add Package

bunx jsr add @std/cache

Import symbol

import { type MemoizeOptions } from "@std/cache/memoize";