MCPcopy Index your code
hub / github.com/tensorflow/tfjs / setMaxEntries

Method setMaxEntries

tfjs-layers/src/utils/executor_utils.ts:63–78  ·  view source on GitHub ↗

* Set the MaxEntries of the cache. If the maxEntries is decreased, reduce * entries in the cache.

(maxEntries: number)

Source from the content-addressed store, hash-verified

61 * entries in the cache.
62 */
63 public setMaxEntries(maxEntries: number): void {
64 if (maxEntries < 0) {
65 throw new Error(
66 `The maxEntries of LRU caches must be at least 0, but got ${
67 maxEntries}.`);
68 }
69
70 if (this.maxEntries > maxEntries) {
71 for (let i = 0; i < this.maxEntries - maxEntries; i++) {
72 const keyToDelete = this.cache.keys().next().value;
73 this.cache.delete(keyToDelete);
74 }
75 }
76
77 this.maxEntries = maxEntries;
78 }
79}

Callers 2

updateCacheMaxEntriesFunction · 0.80

Calls 2

deleteMethod · 0.80
nextMethod · 0.45

Tested by

no test coverage detected