Skip to content

Commit

Permalink
docs: minor things
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien-R44 committed Feb 1, 2025
1 parent 1aea107 commit 555a81d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
5 changes: 4 additions & 1 deletion docs/content/docs/cache_drivers.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ const bento = new BentoCache({
default: 'memory',
stores: {
memory: bentostore().useL1Layer(memoryDriver({
maxSize: 10 * 1024 * 1024,
maxSize: '10mb',
maxEntrySize: '1mb',
maxItems: 1000
}))
}
Expand All @@ -111,6 +112,8 @@ const bento = new BentoCache({
| `maxItems` | The maximum number of entries that the cache can contain. Note that fewer items may be stored if you are also using `maxSize` and the cache is full. | N/A |
| `maxEntrySize` | The maximum size of a single entry in bytes. | N/A |

`maxSize` and `maxEntrySize` accept human-readable strings. We use [bytes](https://www.npmjs.com/package/bytes) under the hood so make sure to ensure the format is correct. A `number` can also be passed to these options.

## DynamoDB

DynamoDB is also supported by bentocache. You will need to install `@aws-sdk/client-dynamodb` to use this driver.
Expand Down
2 changes: 1 addition & 1 deletion docs/content/docs/grace_periods.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ bento.getOrSet({
})
```

In this example, if the factory fails, we will wait 5 minutes before trying again.
In this example, if the factory fails, we will wait 5 minutes before trying again. In other words, we will extend the `ttl` of the cache entry by 5 minutes, so BentoCache will not try to call the factory again and again.
3 changes: 1 addition & 2 deletions docs/content/docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Bentocache is a robust multi-tier caching library for Node.js applications
- 🔄 Synchronization of local cache via Bus
- 🚀 Many drivers (Redis, Upstash, In-memory, Postgres, Sqlite and others)
- 🛡️ Grace period and timeouts. Serve stale data when the store is dead or slow
- 🤓 SWR-like caching strategy
- 🗂️ Namespaces. Group your keys by categories.
- 🛑 Cache stamped protection.
- 🏷️ Named caches
Expand All @@ -28,8 +29,6 @@ Not to knock them, on the contrary, they have their use cases and cool. Some are

Bentocache, on the other hand, is a **full-featured caching library**. We indeed have this notion of unified access to different drivers, but in addition to that, we have a ton of features that will allow you to do robust caching.

With that in mind, then I believe there is no serious alternative to Bentocache in the JavaScript ecosystem. Which is regrettable, because all other languages have powerful solutions. This is why Bentocache was created.

## Quick presentation

Bentocache is a caching solution aimed at combining performance and flexibility. If you are looking for a caching system that can transition from basic use to advanced multi-level configuration, you are in the right place. Here's what you need to know :
Expand Down
27 changes: 24 additions & 3 deletions docs/content/docs/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,16 @@ The TTL of the item to cache. See [TTL formats](#ttl-formats).

### `suppressL2Errors`

Default: `false`
Default: `true` if L1 and L2 Caches are enabled. `false` if only L2 Cache is enabled.

Levels: `global`, `store`, `operation`

If `false`, then errors thrown by your L2 cache will be rethrown, and you will have to handle them yourself. Otherwise, they will just be ignored.

Note that in some cases, like when you use [Grace Periods](./grace_periods.md), errors will not be thrown, even if this option is set to `false`. Since this is the whole point of grace periods.

Note that event if errors are suppressed and not thrown, they will still be logged if you have a logger configured.

### `grace`

Default `undefined`
Expand All @@ -89,10 +91,10 @@ A duration to define the [grace backoff](./grace_periods.md).

### `timeout`

Default: `undefined`
Default: `0`
Levels: `global`, `store`, `operation`

A duration to define a soft [timeout](./timeouts.md#soft-timeouts).
A duration to define a soft [timeout](./timeouts.md#soft-timeouts). By default, this is `0`, which means : if we have a stale value in cache, we will return it immediately, and start a background refresh.

### `hardTimeout`

Expand All @@ -111,6 +113,25 @@ The maximum amount of time (in milliseconds) that the in-memory lock for [stampe

This is usually not needed, but can provide an extra layer of protection against theoretical deadlocks.

### `onFactoryError`

Default: `undefined`

A function that will be called when a factory, running in background or not, throws an error. This can be useful for logging or monitoring purposes.

```ts
const bento = new BentoCache({
default: 'memory',
onFactoryError: (error) => {
console.error('Factory error', error, 'when trying to fetch for key', error.key)
console.log(error.isBackground)
}
stores: {
memory: bentostore().useL1Layer(memoryDriver({})),
},
})
```

### `serializer`

Default: `JSON.stringify` and `JSON.parse`
Expand Down

0 comments on commit 555a81d

Please sign in to comment.