Skip to content

Commit

Permalink
improve readme
Browse files Browse the repository at this point in the history
  • Loading branch information
uriva committed Nov 11, 2023
1 parent 7c0c2ea commit 026627c
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
`rmmbr` is the simplest way to persistently cache async functions, locally or in
the cloud with end to end encryption (e2ee).

Most importantly, it does not require any DevOps work, or cloud configurations. It just works.
Most importantly, it does not require any DevOps work, or cloud configurations.
It just works.

## Motivation

Expand Down Expand Up @@ -160,6 +161,27 @@ import { waitAllWrites } from "rmmbr";
await waitAllWrites();
```

#### Custom key function

By default, `rmmbr` will generate a cache key for you, from any serializable
simple json object. If you want to override this behaviour, you can give your
own key function, which should get the same parameters as your function, and
return any simple json object.

For example:

```ts
const f = cache({
cacheId: "some id",
customKeyFn: (x) => x % 2 === 0, // check if x is even or odd
})((x: number, y: number) => Promise.resolve(x));

await f(1);
await f(1); // identical call, will use cache
await f(3); // odd number, and the custom ket function treats it the same as `1`, so will use the cache
await f(2); // would cause a call, because 2 is even
```

## Pricing

| Tier | Requests | Total data stored | Max entry size | # Entries |
Expand Down

0 comments on commit 026627c

Please sign in to comment.