0.0.1 • Published 6 months ago

node-keyv-fetch-cache v0.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
6 months ago

This package allows you to use keyvhq with node-fetch-cache, enabling access to all kind of different caching mechanisms like redis, mongo, sqlite, postgres etc.

To use try the following,

pnpm i node-keyv-fetch-cache
import { fetchBuilder } from "node-fetch-cache";
import KeyvSQLite from "@keyvhq/sqlite";
import { KeyvFetchCache } from "node-keyv-fetch-cache"

// create a backing store for the cache
const store = new KeyvSQLite("sqlite://path/to/datastore.sqlite");
// use the store with keyv to create a cache, defaults to a in-memory store
const cache = new KeyvFetchCache({ store });
// create fetch with the cache we just created
const fetch = fetchBuilder.withCache(cache);

// let's check your IP or any other kind of request
// run the command multiple time to ensure it gets data from the store
fetch("http://httpbin.org/ip")
  .then((data) => data.text())
  .then(console.log);
0.0.1

6 months ago