From 4d8bcdeb84eac939f632b097b4ec737621a0fcfc Mon Sep 17 00:00:00 2001 From: Jason Mooberry Date: Mon, 10 Nov 2014 15:24:35 -0500 Subject: [PATCH] Adding meaningful constant expirations --- cache.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cache.go b/cache.go index de300fa..eaee322 100644 --- a/cache.go +++ b/cache.go @@ -83,6 +83,11 @@ type cache struct { janitor *janitor } +const ( + NoExpiration time.Duration = -1 + DefaultExpiration time.Duration = 0 +) + // Add an item to the cache, replacing any existing item. If the duration is 0, // the cache's default expiration time is used. If it is -1, the item never // expires. @@ -96,7 +101,7 @@ func (c *cache) Set(k string, x interface{}, d time.Duration) { func (c *cache) set(k string, x interface{}, d time.Duration) { var e *time.Time - if d == 0 { + if d == DefaultExpiration { d = c.defaultExpiration } if d > 0 {