cachu
Simple, minimalistic key-value cache, created by Azury.
Why should you use cachu?
- fully asynchronous
- small n' easy
- zero dependencies
Installation
Install the Package
Install it using your favorite package manager.
npm i cachu
yarn add cachu
Class Instance
Recommended if you need multiple caches.
import { Cachu } from 'cachu'
const cache = new Cachu({
max: 10,
maxAge: 60
})
(async () => {
await cache.setItem(123, 'hello world')
console.log(await cache.getItem(123))
})()
Global Instance
Recommended if you need only one cache or want to configure cachu globally.
import cachu, { setItem, getItem } from 'cachu'
cachu({
max: 10,
maxAge: 60
})
(async () => {
await setItem(123, 'hello world')
console.log(await getItem(123))
})()
API
Configuration
maxAge
to set the maximum age for each item in the storemaxAmount
to set the maximum size for the store
Features