Skip to content

Commit 5c26e91

Browse files
authored
refactor: maxEntryCount (#3832)
1 parent 5ac4fb8 commit 5c26e91

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

lib/cache/memory-cache-store.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const { Writable } = require('node:stream')
1313
* }} MemoryStoreValue
1414
*/
1515
class MemoryCacheStore {
16-
#maxEntries = Infinity
16+
#maxCount = Infinity
1717

1818
#maxEntrySize = Infinity
1919

@@ -33,15 +33,15 @@ class MemoryCacheStore {
3333
throw new TypeError('MemoryCacheStore options must be an object')
3434
}
3535

36-
if (opts.maxEntries !== undefined) {
36+
if (opts.maxCount !== undefined) {
3737
if (
38-
typeof opts.maxEntries !== 'number' ||
39-
!Number.isInteger(opts.maxEntries) ||
40-
opts.maxEntries < 0
38+
typeof opts.maxCount !== 'number' ||
39+
!Number.isInteger(opts.maxCount) ||
40+
opts.maxCount < 0
4141
) {
42-
throw new TypeError('MemoryCacheStore options.maxEntries must be a non-negative integer')
42+
throw new TypeError('MemoryCacheStore options.maxCount must be a non-negative integer')
4343
}
44-
this.#maxEntries = opts.maxEntries
44+
this.#maxCount = opts.maxCount
4545
}
4646

4747
if (opts.maxEntrySize !== undefined) {
@@ -58,7 +58,7 @@ class MemoryCacheStore {
5858
}
5959

6060
get isFull () {
61-
return this.#entryCount >= this.#maxEntries
61+
return this.#entryCount >= this.#maxCount
6262
}
6363

6464
/**

types/cache-interceptor.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,13 @@ declare namespace CacheHandler {
7777
/**
7878
* @default Infinity
7979
*/
80-
maxEntries?: number
80+
maxCount?: number
81+
8182
/**
8283
* @default Infinity
8384
*/
8485
maxEntrySize?: number
86+
8587
errorCallback?: (err: Error) => void
8688
}
8789

0 commit comments

Comments
 (0)