🚀. Socket Launch Week Day 3:Socket Firewall Now Blocks Malicious VS Code and Open VSX Extensions.Learn more
Sign In

@arcjet/cache

Package Overview
Dependencies
Maintainers
3
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@arcjet/cache

Arcjet cache interface and implementations

Source
npmnpm
Version
1.0.0-beta.18
Version published
Weekly downloads
57K
2.87%
Maintainers
3
Weekly downloads
 
Created
Source
Arcjet Logo

@arcjet/cache

npm badge

Arcjet cache interface and implementations.

What is this?

This is an internal utility to help us cache some things in memory.

When should I use this?

This is an internal Arcjet package not designed for public use. See our Get started guide for how to use Arcjet in your application.

Install

This package is ESM only. Install with npm in Node.js:

npm install @arcjet/cache

Use

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 ]

API

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): void

Makes a best attempt at storing the value provided until the time-to-live specified.

Non-string arguments will cause the function to throw.

License

Apache License, Version 2.0 © Arcjet Labs, Inc.

Keywords

arcjet

FAQs

Package last updated on 22 Jan 2026

Did you know?

Socket

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.

Install

Related posts