From d8877e5400f294651364c1568733eec2698fbbeb Mon Sep 17 00:00:00 2001 From: flakey5 <73616808+flakey5@users.noreply.github.com> Date: Wed, 16 Oct 2024 00:14:27 -0700 Subject: [PATCH] docs Signed-off-by: flakey5 <73616808+flakey5@users.noreply.github.com> --- docs/docs/api/CacheStore.md | 15 ++++++++++++++- lib/cache/sqlite-cache-store.js | 8 ++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/docs/docs/api/CacheStore.md b/docs/docs/api/CacheStore.md index f4dcbb927c1..a323f142ac2 100644 --- a/docs/docs/api/CacheStore.md +++ b/docs/docs/api/CacheStore.md @@ -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 diff --git a/lib/cache/sqlite-cache-store.js b/lib/cache/sqlite-cache-store.js index 7708d421191..79d8ec0cbe0 100644 --- a/lib/cache/sqlite-cache-store.js +++ b/lib/cache/sqlite-cache-store.js @@ -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) { @@ -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 } @@ -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 }