MCPcopy
hub / github.com/ampproject/amphtml / evict_

Method evict_

src/core/data-structures/lru-cache.js:65–85  ·  view source on GitHub ↗

* Evicts the oldest cache entry, if we've exceeded capacity.

()

Source from the content-addressed store, hash-verified

63 * Evicts the oldest cache entry, if we've exceeded capacity.
64 */
65 evict_() {
66 if (this.size_ <= this.capacity_) {
67 return;
68 }
69
70 const cache = this.cache_;
71 let oldest = this.access_ + 1;
72 let oldestKey;
73 for (const key in cache) {
74 const {access} = cache[key];
75 if (access < oldest) {
76 oldest = access;
77 oldestKey = key;
78 }
79 }
80
81 if (oldestKey !== undefined) {
82 delete cache[oldestKey];
83 this.size_--;
84 }
85 }
86}

Callers 1

putMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected