Skip to main content

Simple persistent caching.

Project description

rmmbr is the simplest way to cache your async functions, locally or in the cloud.

Usage:

npm i rmmbr
import { cloudCache, localCache } from "rmmbr";

const cacher = localCache({ id: "name of cache for my function" });

let nCalled = 0;
const f = (x: number) => {
  nCalled++;
  return Promise.resolve(x);
};
const fCached = cacher(f);
await fCached(3);
await fCached(3);
// nCalled is 1 here

The local cache stores data in a text file under a .rmmbr directory.

There is also a memCache, if you are feeling nostalgic 😉 and just want to store stuff in memory.

To persist the cache across devices, we offer a use cloud service, which is free to use up to a quota.

To use it, you can install the CLI tool:

source <(curl -s https://raw.githubusercontent.com/uriva/rmmbr/main/cli/install.sh)

Then

rmmbr login
rmmbr api-token

You can then use your token with the API as follows:

const cacher = cloudCache({
  token: "service-token",
  cacheId: "some name for the cache",
  url: "https://uriva-rmmbr.deno.dev",
  ttl: 60 * 60 * 24, // Values will expire after one day, omission of this field implies max.
});

If your data is sensitive, you can e2e encrypt it by adding an encryptionKey parameter.

To produce an encryption key:

rmmbr secret

Then use it like so:

const cacher = cloudCache({
  token: "service-token",
  cacheId: "some name for the cache",
  url: "https://uriva-rmmbr.deno.dev",
  encryptionKey: "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
});

Python

pip install rmmbr

The python api mimicks the js one, with exported decorators named mem_cache, local_cache and cloud_cache.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rmmbr-0.0.5.tar.gz (4.7 kB view hashes)

Uploaded Source

Built Distribution

rmmbr-0.0.5-py3-none-any.whl (5.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page