MCPcopy Create free account
hub / github.com/21st-dev/1code / evictLRU

Method evictLRU

src/main/lib/git/cache/git-cache.ts:164–186  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

162 }
163
164 private evictLRU(): void {
165 let lruKey: string | null = null;
166 let lruAccessCount = Number.POSITIVE_INFINITY;
167 let lruTimestamp = Number.POSITIVE_INFINITY;
168
169 const entries = Array.from(this.cache.entries());
170 for (const [key, entry] of entries) {
171 // Prioritize by access count, then by timestamp
172 if (
173 entry.accessCount < lruAccessCount ||
174 (entry.accessCount === lruAccessCount &&
175 entry.timestamp < lruTimestamp)
176 ) {
177 lruKey = key;
178 lruAccessCount = entry.accessCount;
179 lruTimestamp = entry.timestamp;
180 }
181 }
182
183 if (lruKey) {
184 this.delete(lruKey);
185 }
186 }
187}
188
189/**

Callers 1

evictIfNeededMethod · 0.95

Calls 1

deleteMethod · 0.95

Tested by

no test coverage detected