Skip to content

Commit

Permalink
feat: don't update cache when there is an error
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Gleich <[email protected]>
  • Loading branch information
gleich committed Dec 7, 2024
1 parent ba261d2 commit 9210e48
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions internal/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,10 @@ func (c *Cache[T]) StartPeriodicUpdate(updateFunc func() (T, error), interval ti
defer ticker.Stop()
for range ticker.C {
data, err := updateFunc()
if err != nil && !errors.Is(err, apis.WarningError) {
lumber.Error(err, "updating", c.name, "cache failed")
if err != nil {
if !errors.Is(err, apis.WarningError) {
lumber.Error(err, "updating", c.name, "cache failed")
}
} else {
c.Update(data)
}
Expand Down

0 comments on commit 9210e48

Please sign in to comment.