MCPcopy Create free account
hub / github.com/Datakitpage/Datakit / cleanup

Method cleanup

backend/api/src/postgres-proxy/utils/cache.util.ts:182–198  ·  view source on GitHub ↗

* Cleanup expired entries

()

Source from the content-addressed store, hash-verified

180 * Cleanup expired entries
181 */
182 cleanup(): number {
183 let removedCount = 0;
184 const now = Date.now();
185
186 for (const [key, entry] of this.cache.entries()) {
187 if (now - entry.timestamp > this.options.ttl) {
188 this.cache.delete(key);
189 removedCount++;
190 }
191 }
192
193 if (removedCount > 0 && this.options.enableStats) {
194 this.logger.log(`Cleaned up ${removedCount} expired cache entries`);
195 }
196
197 return removedCount;
198 }
199
200 /**
201 * Evict least recently used entry

Callers 2

constructorMethod · 0.95
cache.util.spec.tsFile · 0.80

Calls 1

deleteMethod · 0.45

Tested by

no test coverage detected