Simple in-memory key-value cache with optional periodic auto-clearing.
import {Cache} from "./Cache.js"
const cache = new Cache({clearInterval: 30000})
cache.put("user", {name: "Alice"})
cache.get("user") // {name: "Alice"}
cache.clear("user") // remove single entry
cache.clearAll() // remove all entries| Prop | Default | Description |
|---|---|---|
clearInterval |
30000 |
Auto-clear interval in ms. Set to 0 to disable |
put(key, value)— store a valueget(key)— retrieve a valueclear(key)— remove a single entryclearAll()— remove all entries