Skip to content

warsam-e/stash

Repository files navigation

@warsam-e/stash

A simple and flexible caching library for TypeScript

npm version npm downloads

Installation

% bun i @warsam-e/stash

Usage

import { Stash } from '@warsam-e/stash';

const stash = new Stash("example-key"); // default driver -> InMemoryDriver

async function orig_data() { ... }
const data = () => stash.wrap("item-key", "1 hour later", () => orig_data())

data().then(console.log);
// after the first, any calls to the same key (with the matching duration)
// will return the cached value

Drivers

  • InMemoryDriver: The default driver, stores data in memory.
  • RedisDriver: Stores data in a Redis database.
  • SqliteDriver: Stores data in a SQLite file.

About

A simple and flexible caching library for JavaScript and TypeScript

Resources

License

Stars

Watchers

Forks