Skip to content

Commit

Permalink
Merge pull request #1185 from fluxcd/fix-cache-ttl-set
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddeco authored Aug 1, 2023
2 parents 96f6041 + 7cc8b94 commit 38cff76
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions internal/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (c *cache) Delete(key string) {
}

// Clear all items from the cache.
// This reallocate the inderlying array holding the items,
// This reallocates the underlying array holding the items,
// so that the memory used by the items is reclaimed.
func (c *cache) Clear() {
c.mu.Lock()
Expand Down Expand Up @@ -163,11 +163,10 @@ func (c *cache) HasExpired(key string) bool {
func (c *cache) SetExpiration(key string, expiration time.Duration) {
c.mu.Lock()
item, ok := c.Items[key]
if !ok {
c.mu.Unlock()
return
if ok {
item.Expiration = time.Now().Add(expiration).UnixNano()
c.Items[key] = item
}
item.Expiration = time.Now().Add(expiration).UnixNano()
c.mu.Unlock()
}

Expand Down

0 comments on commit 38cff76

Please sign in to comment.