
Company News
Free Business Plan Upgrades for Open Source Maintainers
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.
@arcjet/cache
Advanced tools
@arcjet/cacheArcjet cache interface and implementations.
This is an internal utility to help us cache some things in memory.
This is an internal Arcjet package not designed for public use. See our Get started guide for how to use Arcjet in your application.
This package is ESM only. Install with npm in Node.js:
npm install @arcjet/cache
import { setTimeout } from "node:timers/promises";
import { MemoryCache } from "@arcjet/cache";
const cache = new MemoryCache<string>();
cache.set("namespace", "key", "value", 2);
console.log(await cache.get("namespace", "key"));
// => [ 'value', 2 ]
await setTimeout(2001);
console.log(await cache.get("namespace", "key"));
// => [ undefined, 0 ]
MemoryCache#constructor()Instantiate the MemoryCache using new MemoryCache() without any arguments.
MemoryCache#get(namespace: string, key: string): Promise<[T | undefined, number]>Attempts to retrieve a value from the cache. If a value exists, it will be returned with the remaining time-to-live (in seconds).
Non-string arguments will cause the returned promise to reject.
MemoryCache#set(namespace: string, key: string, value: T, ttl: number): voidMakes a best attempt at storing the value provided until the time-to-live specified.
Non-string arguments will cause the function to throw.
FAQs
Arcjet cache interface and implementations
The npm package @arcjet/cache receives a total of 61,135 weekly downloads. As such, @arcjet/cache popularity was classified as popular.
We found that @arcjet/cache demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.

Security News
The supply chain control that delays freshly published gems now covers lockfile generation and gem vendoring in Ruby projects.

Security News
During a UK cyber test, a Mythos 5 agent used sockpuppets, social engineering, and prompt injection to try to get a maintainer to merge malware.