MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / cleanupExpiredEntries

Function cleanupExpiredEntries

web/src/app/api/v1/ads/impression/_post.ts:31–38  ·  view source on GitHub ↗

* Clean up expired entries from the rate limiter to prevent memory leaks. * Called periodically during rate limit checks.

()

Source from the content-addressed store, hash-verified

29 * Called periodically during rate limit checks.
30 */
31function cleanupExpiredEntries(): void {
32 const now = Date.now()
33 for (const [userId, limit] of impressionRateLimiter) {
34 if (now >= limit.resetAt) {
35 impressionRateLimiter.delete(userId)
36 }
37 }
38}
39
40// Track last cleanup time to avoid cleaning up on every request
41let lastCleanupTime = 0

Callers 1

checkRateLimitFunction · 0.70

Calls 1

deleteMethod · 0.80

Tested by

no test coverage detected