cachu
v7.0.0
Published
👾 A simple key-value cache for Node.js.
Readme
cachu
Setup
# Get the latest release.
npm i cachuUsage
import { Cache } from 'cachu'
const cache = new Cache({
maximumAge: '10m', // 10 minutes, can be specified as number (in seconds) or readable string
...
})
// Add a new record.
await cache.add('one', 'Hello World')
const record = await cache.get('one') // 'Hello World'API
Configuration (optional)
autodeleteto delete overaged entries on adding/updating (disabled by default)maximumAgeto set the maximum age for each record in the cache (defaults to 600s)maximumAmountto set the maximum size for the cache (defaults to 10000)maximumRecordSizeto set the maximum size for each record (defaults to 10 KB)
Features
add()addMany()get()getMany()update()updateMany()remove()removeMany()has()size()(get the cache size in bytes)keys()values()clear()(delete all overaged records manually)
