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 = MemoryCache()
await cache.set('one', 'Hello Github')
const { value } = await cache.get('one')
})()
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, maxAge)
setMany([[key, value, maxAge]])
get(key, config)
getMany([keys], config)
update(key, value, config)
updateMany([[key, value]], config)
delete(key)
deleteMany([keys])
has(key)
size()
keys()
values()
clear()
recent()
maxAge(age)
maxAmount(amount)
oldest()
newest()
on(event, action)
dump()