πŸ“œ Events

Listen to all events occurring in your cache.

Overview

Being able to listen to events occurring in our cache is very important in order to know whenever something expires, is deleted, or any other action you need.


To do this, we have developed the addEventListener method, which will help you understand everything that happens inside.

Set Event
import { Cache } from "toolkitify/cache";

const cache = new Cache();

cache.addEventListener("set", (data) => {
    // data: {"storage":"memory","key":"foo","value":"value-46524","uses":0,"ttl":60000,"expiresAt":"11/11/2025, 3:27:00 PM","msRemaining":60000}
})

Interfaces

ParameterTypeRequiredDescription
eventEventβœ…Event to listen to
callbackFunctionβœ…Callback to execute

Event

ParameterType
eventset | get | delete | clear | expire