Skip to content

Commit

Permalink
feat: update periodically without using ticker
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Gleich <[email protected]>
  • Loading branch information
gleich committed Jan 7, 2025
1 parent 20e4f7c commit e5eaa48
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions internal/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,8 @@ func (c *Cache[T]) Update(data T) {
}

func (c *Cache[T]) UpdatePeriodically(update func() (T, error), interval time.Duration) {
ticker := time.NewTicker(interval)
defer ticker.Stop()
for range ticker.C {
for {
time.Sleep(interval)
data, err := update()
if err != nil {
if !errors.Is(err, apis.WarningError) {
Expand Down

0 comments on commit e5eaa48

Please sign in to comment.