MCPcopy
hub / github.com/seaweedfs/seaweedfs / Cleanup

Method Cleanup

weed/mq/kafka/protocol/response_cache.go:58–68  ·  view source on GitHub ↗

Cleanup removes expired entries from the cache

()

Source from the content-addressed store, hash-verified

56
57// Cleanup removes expired entries from the cache
58func (c *ResponseCache) Cleanup() {
59 c.mu.Lock()
60 defer c.mu.Unlock()
61
62 now := time.Now()
63 for key, entry := range c.cache {
64 if now.Sub(entry.timestamp) > c.ttl {
65 delete(c.cache, key)
66 }
67 }
68}
69
70// StartCleanupLoop starts a background goroutine to periodically clean up expired entries
71func (c *ResponseCache) StartCleanupLoop(interval time.Duration) {

Calls 3

NowMethod · 0.80
LockMethod · 0.45
UnlockMethod · 0.45