savvy-cache
Keyless mode
import savvy from "savvy-cache";
const doSomething = () => "did something";
const secondsUntilRefresh = 60;
const cache = savvy(doSomething, secondsUntilRefresh);
async function run() {
const value = await cache.get();
console.log(`Whoo savvy-cache ${value}!`);
}
Key mode
import savvy from "savvy-cache";
const doSomething = (key) => `did something with ${key}`;
const cache = savvy(doSomething);
async function run() {
const value = await cache.get("id");
console.log(`Whoo savvy-cache ${value}!`);
}