Adding meaningful constant expirations
This commit is contained in:
parent
7d1d6d6ae9
commit
4d8bcdeb84
7
cache.go
7
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 {
|
||||
|
|
Loading…
Reference in New Issue