1.0.0 • Published 2 years ago

@stellaraf/cacheutil v1.0.0

Weekly downloads
-
License
BSD-3-Clause
Repository
-
Last release
2 years ago

@stellaraf/cacheutil provides a consistent caching API with support for multiple backends, in the event that a library requires a cache but could be used on multiple platforms with different caching systems available. For example, if one needed use a library on both Cloudflare Workers and a standard NodeJS application.

Supported Backends

Cloudflare KV

import { createCache } from "@stellaraf/cacheutil-cache";

const cache = createCache(env.KV_BINDING);

await cache.set("key", "value");
const value = await cache.get("key");
console.log(value);
// value

Redis

import { createCache } from "@stellaraf/cacheutil-cache";

const cache = createCache({ url: "redis://localhost:6379", database: 1 });

await cache.set("key", "value");
const value = await cache.get("key");
console.log(value);
// value