1.2.1 • Published 3 years ago

savvy-cache v1.2.1

Weekly downloads
9
License
MIT
Repository
github
Last release
3 years ago

savvy-cache

Keyless mode

import savvy from "savvy-cache";

// doSomething function does not require a key
const doSomething = () => "did something";

// secondsUntilRefresh will refresh cache between calls to cache.get
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";

// doSomething example with a key
const doSomething = (key) => `did something with ${key}`;

// when secondsUntilRefresh is not provided, cache will never be refreshed
const cache = savvy(doSomething);

async function run() {
  const value = await cache.get("id");
  console.log(`Whoo savvy-cache ${value}!`);
}
1.2.1

3 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago