🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@resolid/cache

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@resolid/cache

Type-safe Async Cache for TypeScript

Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
7
-86.79%
Maintainers
1
Weekly downloads
 
Created
Source

Type-safe Async Cache for TypeScript

GitHub License NPM Version

Documentation | Framework Bundle

A fully-typed, flexible cache system for modern TypeScript projects. Supports single and batch operations, optional TTL, and pluggable storage backends. Designed for libraries, frameworks, and applications needing predictable async caching.

Feature

  • Fully typed with TypeScript — no any.
  • Supports get/set/del/clear operations.
  • Supports batch operations: getMultiple, setMultiple, delMultiple.
  • Optional TTL for automatic expiration.
  • Pluggable store backend (default is nullCache).
  • Detects existence of keys via has.
  • Handles disposal of resources via dispose.

Installation

pnpm add @resolid/cache
# or
npm install @resolid/cache
# or
yarn add @resolid/cache
# or
bun add @resolid/cache

Usage

import { Cacher } from "@resolid/cache";

const cache = new Cacher({ defaultTtl: 1000 });

// Single set/get
await cache.set("foo", { a: 1 });
const value = await cache.get("foo"); // -> { a: 1 }

// Check existence
const exists = await cache.has("foo"); // -> true

// Batch set/get
await cache.setMultiple({ key1: 1, key2: 2 });
const values = await cache.getMultiple(["key1", "key2"]); // -> [1, 2]

// Delete
await cache.del("foo");
await cache.delMultiple(["key1", "key2"]);

// Clear all
await cache.clear();

// Dispose store if necessary
await cache.dispose();

Options

export interface CacheOptions {
  store?: CacheStore;
  defaultTtl?: number;
}

Store Interface

Your custom store should implement CacheStore:

export interface CacheStore {
  get(key: string): Promise<string | undefined>;
  set(key: string, value: string, ttl?: number): Promise<boolean>;
  del(key: string): Promise<boolean>;
  clear(): Promise<boolean>;

  getMultiple?(keys: string[]): Promise<(string | undefined)[]>;
  setMultiple?(values: Record<string, string>, ttl?: number): Promise<boolean>;
  delMultiple?(keys: string[]): Promise<boolean>;
  has?(key: string): Promise<boolean>;
  dispose?(): Promise<void> | void;
}

License

MIT License (MIT). Please see LICENSE for more information.

Keywords

cache

FAQs

Package last updated on 25 Feb 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