UNPKG

atikin-cache-ninja

Version:

A smart caching utility that optimizes app performance by providing in-memory caching with expiry, automatic invalidation, and async support.

13 lines (9 loc) 395 B
const CacheNinja = require("./index"); const cache = new CacheNinja("LRU", 3); cache.set("a", 1, 5000); cache.set("b", 2); cache.set("c", 3); console.log(cache.get("a")); // Should return 1 cache.set("d", 4); // Should evict one entry based on LRU strategy console.log(cache.get("b")); // Should return null if evicted console.log(cache.getStats()); // Should show hit/miss rates