MCPcopy Create free account
hub / github.com/nodejs/undici / constructor

Method constructor

lib/cache/memory-cache-store.js:31–71  ·  view source on GitHub ↗

* @param {import('../../types/cache-interceptor.d.ts').default.MemoryCacheStoreOpts | undefined} [opts]

(opts)

Source from the content-addressed store, hash-verified

29 * @param {import('../../types/cache-interceptor.d.ts').default.MemoryCacheStoreOpts | undefined} [opts]
30 */
31 constructor (opts) {
32 super()
33 if (opts) {
34 if (typeof opts !== 'object') {
35 throw new TypeError('MemoryCacheStore options must be an object')
36 }
37
38 if (opts.maxCount !== undefined) {
39 if (
40 typeof opts.maxCount !== 'number' ||
41 !Number.isInteger(opts.maxCount) ||
42 opts.maxCount < 0
43 ) {
44 throw new TypeError('MemoryCacheStore options.maxCount must be a non-negative integer')
45 }
46 this.#maxCount = opts.maxCount
47 }
48
49 if (opts.maxSize !== undefined) {
50 if (
51 typeof opts.maxSize !== 'number' ||
52 !Number.isInteger(opts.maxSize) ||
53 opts.maxSize < 0
54 ) {
55 throw new TypeError('MemoryCacheStore options.maxSize must be a non-negative integer')
56 }
57 this.#maxSize = opts.maxSize
58 }
59
60 if (opts.maxEntrySize !== undefined) {
61 if (
62 typeof opts.maxEntrySize !== 'number' ||
63 !Number.isInteger(opts.maxEntrySize) ||
64 opts.maxEntrySize < 0
65 ) {
66 throw new TypeError('MemoryCacheStore options.maxEntrySize must be a non-negative integer')
67 }
68 this.#maxEntrySize = opts.maxEntrySize
69 }
70 }
71 }
72
73 /**
74 * Get the current size of the cache in bytes

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected