Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
Signed-off-by: flakey5 <[email protected]>
  • Loading branch information
flakey5 committed Oct 16, 2024
1 parent a654aa7 commit d8877e5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
15 changes: 14 additions & 1 deletion docs/docs/api/CacheStore.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,20 @@ The `MemoryCacheStore` stores the responses in-memory.
**Options**

- `maxEntries` - The maximum amount of responses to store. Default `Infinity`.
- `maxEntrySize` - The maximum size in bytes that a response's body can be. If a response's body is greater than or equal to this, the response will not be cached.
- `maxEntrySize` - The maximum size in bytes that a response's body can be. If a response's body is greater than or equal to this, the response will not be cached. Default `Infinity`.

### `SqliteCacheStore`

The `SqliteCacheStore` stores the response in a

> [!NOTE]
> This requires the [`--experimental-sqlite`](https://nodejs.org/api/cli.html#--experimental-sqlite) CLI flag to be exposed.
**Options**

- `location` - The location of the database. This can be a file path or `:memory:`. Default `:memory:`.
- `maxEntries` - The maximum amount of responses to store. Default `Infinity`.
- `maxEntrySize` - The maximum size in bytes that a response's body can be. If a response's body is greater than or equal to this, the response will not be cached. Default `Infinity`.

## Defining a Custom Cache Store

Expand Down
8 changes: 4 additions & 4 deletions lib/cache/sqlite-cache-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class SqliteCacheStore {
constructor (opts) {
if (opts) {
if (typeof opts !== 'object') {
throw new TypeError('MemoryCacheStore options must be an object')
throw new TypeError('SqliteCacheStore options must be an object')
}

if (opts.maxEntries !== undefined) {
Expand All @@ -95,7 +95,7 @@ class SqliteCacheStore {
!Number.isInteger(opts.maxEntries) ||
opts.maxEntries < 0
) {
throw new TypeError('MemoryCacheStore options.maxEntries must be a non-negative integer')
throw new TypeError('SqliteCacheStore options.maxEntries must be a non-negative integer')
}
this.#maxEntries = opts.maxEntries
}
Expand All @@ -106,14 +106,14 @@ class SqliteCacheStore {
!Number.isInteger(opts.maxEntrySize) ||
opts.maxEntrySize < 0
) {
throw new TypeError('MemoryCacheStore options.maxEntrySize must be a non-negative integer')
throw new TypeError('SqliteCacheStore options.maxEntrySize must be a non-negative integer')
}
this.#maxEntrySize = opts.maxEntrySize
}

if (opts.errorCallback !== undefined) {
if (typeof opts.errorCallback !== 'function') {
throw new TypeError('MemoryCacheStore options.errorCallback must be a function')
throw new TypeError('SqliteCacheStore options.errorCallback must be a function')
}
this.#errorCallback = opts.errorCallback
}
Expand Down

0 comments on commit d8877e5

Please sign in to comment.