Skip to main content

@std/cache@0.1.3
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.1.3)

In-memory cache utilities, such as memoization and caches with different expiration policies.

import { memoize, LruCache } from "@std/cache";
import { assertEquals } from "@std/assert";

const cache = new LruCache<unknown, bigint>(1000);

// fibonacci function, which is very slow for n > ~30 if not memoized
const fib = memoize((n: bigint): bigint => {
  return n <= 2n ? 1n : fib(n - 1n) + fib(n - 2n);
}, { cache });

assertEquals(fib(100n), 354224848179261915075n);
Built and signed on
GitHub Actions
View transparency log

Add Package

deno add jsr:@std/cache

Import symbol

import * as cache from "@std/cache";

---- OR ----

Import directly with a jsr specifier

import * as cache from "jsr:@std/cache";

Add Package

npx jsr add @std/cache

Import symbol

import * as cache from "@std/cache";

Add Package

yarn dlx jsr add @std/cache

Import symbol

import * as cache from "@std/cache";

Add Package

pnpm dlx jsr add @std/cache

Import symbol

import * as cache from "@std/cache";

Add Package

bunx jsr add @std/cache

Import symbol

import * as cache from "@std/cache";