Skip to content

Commit

Permalink
docs and getter
Browse files Browse the repository at this point in the history
Signed-off-by: Matteo Collina <hello@matteocollina.com>
  • Loading branch information
mcollina committed Nov 21, 2024
1 parent f750252 commit 27f1d63
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion docs/docs/api/CacheStore.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ The `SqliteCacheStore` is only exposed if the `node:sqlite` api is present.

**Options**

- `maxSize` - The maximum size in bytes that a resposne'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 resposne's body can be. If a response's body is greater than or equal to this, the response will not be cached. Default `Infinity`.
- `maxDbEntries` - The maximum number of entries to store in the database. Default `Infinity`.

## Defining a Custom Cache Store

Expand Down
4 changes: 2 additions & 2 deletions lib/cache/sqlite-cache-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ class SqliteCacheStore {
* @returns {Number} The number of entries removed
*/
prune () {
const total = this.size()
const total = this.size

if (total <= this.#maxDbEntries) {
return
Expand All @@ -353,7 +353,7 @@ class SqliteCacheStore {
* Counts the number of rows in the cache
* @returns {Number}
*/
size () {
get size () {
const { total } = this.#countEntriesQuery.get()
return total
}
Expand Down
2 changes: 1 addition & 1 deletion test/cache-interceptor/sqlite-cache-store-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,5 @@ test('SqliteCacheStore maxDbEntries', async (t) => {
await once(writeResponse(writable, requestBody), 'close')
}

strictEqual(store.size() < 10, true)
strictEqual(store.size < 10, true)
})

0 comments on commit 27f1d63

Please sign in to comment.