Skip to content

Commit

Permalink
fix: reset value & err on refetch
Browse files Browse the repository at this point in the history
  • Loading branch information
abihf committed Dec 8, 2021
1 parent becd4e1 commit 55d4ee6
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,10 @@ func (l *Loader[Key, Value]) refetch(key Key, item *cacheItem[Value]) {
item.mutex.Lock()
defer item.mutex.Unlock()

item.value, item.err = value, err
if err != nil {
item.err = err
item.updateExpire(l.errTtl)
} else {
item.value = value
item.updateExpire(l.ttl)
}
}
Expand Down

0 comments on commit 55d4ee6

Please sign in to comment.