Skip to content

Commit

Permalink
returns item individual ttl when skipTTLExtension is false
Browse files Browse the repository at this point in the history
  • Loading branch information
iczc authored and ReneKroon committed Sep 7, 2021
1 parent 66a3c28 commit 13ad080
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,11 @@ func (cache *Cache) GetByLoaderWithTtl(key string, customLoaderFunction LoaderFu
if exists {
cache.metrics.Retrievals++
dataToReturn = item.data
ttlToReturn = time.Until(item.expireAt)
if !cache.skipTTLExtension {
ttlToReturn = item.ttl
} else {
ttlToReturn = time.Until(item.expireAt)
}
if ttlToReturn < 0 {
ttlToReturn = 0
}
Expand Down

0 comments on commit 13ad080

Please sign in to comment.