npm.io
0.15.1 • Published 3d ago

@nwire/cache

Licence
MIT
Version
0.15.1
Deps
1
Size
10 kB
Vulns
0
Weekly
50

@nwire/cache

Key/value cache contract for Nwire. Ships an in-memory (TTL) default and cachePlugin; resolve Cache from the container and call get/set. Real backends (Redis/Valkey/Upstash) live in adapter packages.

import { cachePlugin, type Cache } from "@nwire/cache";

createApp({ appName: "shop", plugins: [cachePlugin({ defaultTtl: 300 })] });

// in a handler:
const cache = ctx.resolve<Cache>("cache");
await cache.set("user:1", user, { ttl: 60 });
const hit = await cache.get<User>("user:1");

Keywords