{"_id":"@apislash/cache","_rev":"2-4e5b19ca5946e3629dbc52a669928d02","name":"@apislash/cache","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@apislash/cache","version":"1.0.0","license":"MIT","_id":"@apislash/cache@1.0.0","maintainers":[{"name":"jantheon","email":"vonhara@gmail.com"}],"dist":{"shasum":"f039754af3658a4da6c5491291838ff217c159c1","tarball":"https://registry.npmjs.org/@apislash/cache/-/cache-1.0.0.tgz","fileCount":9,"integrity":"sha512-4cM4U3OLTs6YFfCmbO6ynC7u97W4+2L8ms73ay+lC0LKZ/GHO9pzcyUVp3GQR7mWqqYTzfBWitrjSYbB06GlhA==","signatures":[{"sig":"MEYCIQDvAOaFzGO/pFxNHh2D7wfq6dRiGlQjt3+y9LIXxY/gAgIhAMQ3HKkpTHEDN2J6npSXxcd/f5XMGjqSXxPqQtdcZtkH","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":21760},"main":"dist/index.cjs","type":"module","_from":"file:apislash-cache-1.0.0.tgz","types":"dist/index.d.ts","module":"dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"test":"pnpm exec vitest run --passWithNoTests","build":"pnpm exec tsup src/index.ts --format esm,cjs --dts --sourcemap --clean --out-dir dist","typecheck":"tsc -p tsconfig.json --noEmit","test:watch":"pnpm exec vitest"},"_npmUser":{"name":"jantheon","email":"vonhara@gmail.com"},"_resolved":"/tmp/be1d12f64af1196482b9fa39e2db132f/apislash-cache-1.0.0.tgz","_integrity":"sha512-4cM4U3OLTs6YFfCmbO6ynC7u97W4+2L8ms73ay+lC0LKZ/GHO9pzcyUVp3GQR7mWqqYTzfBWitrjSYbB06GlhA==","_npmVersion":"11.14.1","description":"TTL cache with stale-while-revalidate for any TypeScript project — pluggable backend (in-memory included), framework-agnostic. Published by Apislash.","directories":{},"sideEffects":false,"_nodeVersion":"24.15.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.5.0","vitest":"^3.2.4","typescript":"^5.9.2","@types/node":"^20.17.30"},"_npmOperationalInternal":{"tmp":"tmp/cache_1.0.0_1780133791413_0.9279836470526313","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@apislash/cache","version":"1.0.1","description":"TTL cache with stale-while-revalidate for any TypeScript project — pluggable backend (in-memory included), framework-agnostic. Published by Apislash.","type":"module","main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"publishConfig":{"access":"public","main":"dist/index.cjs","module":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}}},"sideEffects":false,"scripts":{"build":"pnpm exec tsup src/index.ts --format esm,cjs --dts --sourcemap --clean --out-dir dist","typecheck":"tsc -p tsconfig.json --noEmit","test":"pnpm exec vitest run --passWithNoTests","test:watch":"pnpm exec vitest"},"devDependencies":{"@types/node":"^20.17.30","tsup":"^8.5.0","typescript":"^5.9.2","vitest":"^3.2.4"},"license":"MIT","repository":{"type":"git","url":"git+https://gitlab.com/apislash/libs/client/cache/ts.git"},"homepage":"https://gitlab.com/apislash/libs/client/cache/ts#readme","bugs":{"url":"https://gitlab.com/apislash/libs/client/cache/ts/-/issues"},"author":{"name":"jantheon","email":"vonhara@gmail.com"},"keywords":["apislash","cache","ttl","memory","lru","typescript"],"gitHead":"fd5787b773ba884dca761b8bff5a0744d43c72d3","_id":"@apislash/cache@1.0.1","_nodeVersion":"20.20.2","_npmVersion":"11.17.0","dist":{"integrity":"sha512-wYMS6fxWeUbaggMChBcgBrt0vxwpOdEE1WxGwr7emGHuq2ZYwZE+jDOAqObRLRfHJUZQlJsgHDo+yrz5pvM2LA==","shasum":"1fa83c163843c71fd1e5289be964ff4207e096ba","tarball":"https://registry.npmjs.org/@apislash/cache/-/cache-1.0.1.tgz","fileCount":9,"unpackedSize":22438,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@apislash%2fcache@1.0.1","provenance":{"predicateType":"https://slsa.dev/provenance/v0.2"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCTRYWfzO2PLnGGdNAs+2B+0wD5cd5/Tw71CYpbjK4oogIgdqZd2NEXsfiS8AhaIfcwkbuj7wDNE107FDKodEGrTCQ="}]},"_npmUser":{"name":"GitLab CI/CD","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"gitlab","oidcConfigId":"oidc:6b80dc16-873e-4ede-83ae-e8b63a1d7f0c"}},"directories":{},"maintainers":[{"name":"jantheon","email":"vonhara@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/cache_1.0.1_1781948613016_0.4531235915612206"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-30T09:36:31.229Z","modified":"2026-06-20T09:43:33.474Z","1.0.0":"2026-05-30T09:36:31.559Z","1.0.1":"2026-06-20T09:43:33.161Z"},"license":"MIT","description":"TTL cache with stale-while-revalidate for any TypeScript project — pluggable backend (in-memory included), framework-agnostic. Published by Apislash.","maintainers":[{"name":"jantheon","email":"vonhara@gmail.com"}],"readme":"# @apislash/cache\n\n**TTL cache with stale-while-revalidate for any TypeScript project.** A small, framework-agnostic caching layer with a pluggable backend (in-memory included) — return cached data instantly, serve stale while revalidating in the background, and refetch when the stale window expires.\n\nGeneric and usable in any app; published and maintained by **Apislash** (offered to customers under the Apislash brand). MIT licensed.\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](./LICENSE)\n\n## Install\n\n```bash\nnpm install @apislash/cache\n```\n\n## Usage\n\n```ts\nimport { CacheClient, MemoryCacheBackend } from \"@apislash/cache\";\n\nconst cache = new CacheClient(new MemoryCacheBackend(), {\n  ttlMs: 60_000,             // fresh for 60s\n  staleWhileRevalidateMs: 300_000, // serve stale up to 5 min while revalidating\n});\n\nconst { data, stale, fromCache } = await cache.get(\"user:42\", () => fetchUser(42));\n\nawait cache.invalidate(\"user:42\");\nawait cache.clear();\n```\n\n`get(key, fetcher, opts?)` returns `{ data, stale, fromCache }`: a cold miss calls the fetcher and stores the result; a warm hit returns instantly; once the TTL passes (but within the stale window) it returns the stale value and revalidates in the background.\n\n## Backends\n\n`CacheBackend` is a simple `get` / `set` / `delete` / `clear` interface. `MemoryCacheBackend` is included; bring your own (Redis, a KV store, or `@apislash/storage`) by implementing the interface.\n\n## License\n\nMIT © Apislash\n","readmeFilename":"README.md","homepage":"https://gitlab.com/apislash/libs/client/cache/ts#readme","keywords":["apislash","cache","ttl","memory","lru","typescript"],"repository":{"type":"git","url":"git+https://gitlab.com/apislash/libs/client/cache/ts.git"},"author":{"name":"jantheon","email":"vonhara@gmail.com"},"bugs":{"url":"https://gitlab.com/apislash/libs/client/cache/ts/-/issues"}}