mirror of
https://github.com/lukaszraczylo/traefikoidc.git
synced 2026-10-16 04:29:15 +00:00
Abstract the cleanup logic and add helper for cache valid.
This commit is contained in:
@@ -178,16 +178,7 @@ func (c *Cache) removeItem(key string) {
|
||||
|
||||
// startAutoCleanup initiates a goroutine that periodically cleans up expired cache items.
|
||||
func (c *Cache) startAutoCleanup() {
|
||||
ticker := time.NewTicker(c.autoCleanupInterval)
|
||||
for {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
c.Cleanup()
|
||||
case <-c.stopCleanup:
|
||||
ticker.Stop()
|
||||
return
|
||||
}
|
||||
}
|
||||
autoCleanupRoutine(c.autoCleanupInterval, c.stopCleanup, c.Cleanup)
|
||||
}
|
||||
|
||||
// Close terminates the auto cleanup goroutine.
|
||||
|
||||
Reference in New Issue
Block a user