cachu
Setup
npm i cachu
Usage
Note - Need an introduction to v6? Here you go!
import { useCache } from 'cachu'
const cache = useCache({
maxAge: '10m',
...
})
await cache.add('one', 'Hello World')
const entry = await cache.get('one')
API
-
Configuration (optional)
maxAge
to set the maximum age for each record in the cache (defaults to 600s)maxAmount
to set the maximum size for the cache (defaults to 10000)autodelete
to delete overaged entries on adding/updating (disabled by default)
-
Features
add()
addMany()
get()
getMany()
update()
updateMany()
remove()
removeMany()
has()
size()
(get the cache size in bytes)keys()
values()
clear()
(delete all overaged entries manually)