cachu
Simple, minimalistic key-value cache, created by Azury.
- fully asynchronous
- small n' easy
- zero dependencies
Setup
Installation
Install cachu using your favorite package manager.
npm i cachu
yarn add cachu
Usage
Just create a new cache, it's as easy as that!
import { MemoryCache } from 'cachu'
(async () => {
const cache = await MemoryCache({
maxAmount: 10000,
maxAge: 600
})
await cache.set(69, 'Hello World')
console.log((await cache.get(69)).value)
})()
Caches
API
-
Configuration
maxAge
to set the maximum age for each record in the cachemaxAmount
to set the maximum size for the cache
-
Features
set(key, value, age)
setMany([[key, value, age]])
get(key, options)
getMany([key], options)
update(key, value, age)
updateMany([[key, value, age]])
delete(key)
deleteMany([key])
has(key)
clear()
size()
values()
keys()
-
Hooks