gorgon-cache
Installation
SKILL.md
Gorgon.js Caching Library
Gorgon is a lightweight (~4kb, ~1.3kb gzipped) TypeScript caching library for async functions. It works in both Node.js and browsers. Its key differentiator is automatic concurrency protection — multiple simultaneous requests for the same cache key are deduplicated, with all callers receiving the same result.
Installation
npm install @gorgonjs/gorgon
# or: pnpm add @gorgonjs/gorgon / yarn add @gorgonjs/gorgon
Core Concepts
- Cache key naming: Use the format
cachetype/{id}/{sub-id}— this enables wildcard clearing (e.g.Gorgon.clear('user/*')) - Concurrency protection: If 10 requests hit
Gorgon.get('key', fn)simultaneously,fnonly executes once. The other 9 wait and share the result. - Errors are never cached: If the async function throws, all waiting callers get the error, but the next request retries fresh.
- Expiry options: milliseconds (
60000), aDateobject,false(cache forever), or omit for no expiry.