Expires bool is redundant with pointer to Time
This commit is contained in:
parent
99360acb31
commit
8f430150d6
7
cache.go
7
cache.go
|
@ -99,7 +99,6 @@ type cache struct {
|
||||||
|
|
||||||
type Item struct {
|
type Item struct {
|
||||||
Object interface{}
|
Object interface{}
|
||||||
Expires bool
|
|
||||||
Expiration *time.Time
|
Expiration *time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,19 +114,15 @@ func (c *cache) Set(k string, x interface{}, d time.Duration) {
|
||||||
defer c.mu.Unlock()
|
defer c.mu.Unlock()
|
||||||
|
|
||||||
var e *time.Time
|
var e *time.Time
|
||||||
expires := true
|
|
||||||
if d == 0 {
|
if d == 0 {
|
||||||
d = c.DefaultExpiration
|
d = c.DefaultExpiration
|
||||||
}
|
}
|
||||||
if d == -1 {
|
if d > 0 {
|
||||||
expires = false
|
|
||||||
} else {
|
|
||||||
t := time.Now().Add(d)
|
t := time.Now().Add(d)
|
||||||
e = &t
|
e = &t
|
||||||
}
|
}
|
||||||
c.Items[k] = &Item{
|
c.Items[k] = &Item{
|
||||||
Object: x,
|
Object: x,
|
||||||
Expires: expires,
|
|
||||||
Expiration: e,
|
Expiration: e,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue