Skip to content

Commit

Permalink
refactor: maxEntryCount
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag committed Nov 13, 2024
1 parent 28b10fa commit e902d7d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions lib/cache/memory-cache-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const { Writable } = require('node:stream')
* }} MemoryStoreValue
*/
class MemoryCacheStore {
#maxEntries = Infinity
#maxEntriesCount = Infinity

#maxEntrySize = Infinity

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

if (opts.maxEntries !== undefined) {
if (opts.maxEntriesCount !== undefined) {
if (
typeof opts.maxEntries !== 'number' ||
!Number.isInteger(opts.maxEntries) ||
opts.maxEntries < 0
typeof opts.maxEntriesCount !== 'number' ||
!Number.isInteger(opts.maxEntriesCount) ||
opts.maxEntriesCount < 0
) {
throw new TypeError('MemoryCacheStore options.maxEntries must be a non-negative integer')
throw new TypeError('MemoryCacheStore options.maxEntriesCount must be a non-negative integer')
}
this.#maxEntries = opts.maxEntries
this.#maxEntriesCount = opts.maxEntriesCount
}

if (opts.maxEntrySize !== undefined) {
Expand All @@ -58,7 +58,7 @@ class MemoryCacheStore {
}

get isFull () {
return this.#entryCount >= this.#maxEntries
return this.#entryCount >= this.#maxEntriesCount
}

/**
Expand Down
2 changes: 1 addition & 1 deletion types/cache-interceptor.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ declare namespace CacheHandler {
/**
* @default Infinity
*/
maxEntries?: number
maxEntriesCount?: number
/**
* @default Infinity
*/
Expand Down

0 comments on commit e902d7d

Please sign in to comment.