@stambha/cache
v0.2.2
Published
Pluggable cache layer for Stambha gateway and bot workers
Maintainers
Readme
@stambha/cache
Pluggable cache for gateway and bot workers — in-memory implementation with TTL support.
Part of Stambha plugins · Stambha framework
Install
npm install @stambha/cacheRequires Node.js 20+.
Quick start
import { createMemoryCache } from "@stambha/cache";
const cache = createMemoryCache({ defaultTtlMs: 60_000 });
await cache.set("guild:g1", { name: "My Server" });
const guild = await cache.get<{ name: string }>("guild:g1");
await cache.delete("guild:g1");Use behind gateway workers to avoid re-fetching guild/channel payloads on every event.
Key exports
| Export | Purpose |
|--------|---------|
| Cache | get / set / delete interface |
| MemoryCache, createMemoryCache | In-process TTL cache |
| CacheSetOptions | Per-key TTL overrides |
Related packages
| Package | Role |
|---------|------|
| @stambha/gateway | Shard workers that benefit from caching |
| @stambha/rest | Fetch missing entities on cache miss |
Development
pnpm --filter @stambha/cache build
pnpm --filter @stambha/cache test