MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / startCleanup

Function startCleanup

server/src/middleware/pg-rate-limit-store.ts:17–29  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15// Periodic cleanup of expired rows (runs once, shared across all stores)
16let cleanupStarted = false;
17function startCleanup(): void {
18 if (cleanupStarted) return;
19 cleanupStarted = true;
20 const timer = setInterval(async () => {
21 if (!isDatabaseInitialized()) return;
22 try {
23 await query(`DELETE FROM rate_limit_hits WHERE reset_at <= NOW()`);
24 } catch (err) {
25 logger.warn({ err }, 'Failed to clean up expired rate limit hits');
26 }
27 }, 5 * 60 * 1000); // every 5 minutes
28 timer.unref();
29}
30
31export class PostgresStore implements Store {
32 private windowMs = 60_000;

Callers 2

constructorMethod · 0.85
constructorMethod · 0.85

Calls 3

isDatabaseInitializedFunction · 0.85
queryFunction · 0.85
warnMethod · 0.80

Tested by

no test coverage detected