Skip to content

Commit 62b62f2

Browse files
committed
handle zero expiry
1 parent cb90d4c commit 62b62f2

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

cache.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ type itemOptions struct {
7777
// WithExpiration is an option to set expiration time for any items.
7878
// If the expiration is zero or negative value, it treats as w/o expiration.
7979
func WithExpiration(exp time.Duration) ItemOption {
80+
if exp <= 0 {
81+
return func(o *itemOptions) {}
82+
}
8083
return func(o *itemOptions) {
8184
o.expiration = nowFunc().Add(exp)
8285
}

0 commit comments

Comments
 (0)