sm
/
cache
1
0
Fork 0

Expires bool is redundant with pointer to Time

This commit is contained in:
Patrick Mylund Nielsen 2012-01-02 17:13:29 +01:00
parent 99360acb31
commit 8f430150d6
1 changed files with 1 additions and 6 deletions

View File

@ -99,7 +99,6 @@ type cache struct {
type Item struct {
Object interface{}
Expires bool
Expiration *time.Time
}
@ -115,19 +114,15 @@ func (c *cache) Set(k string, x interface{}, d time.Duration) {
defer c.mu.Unlock()
var e *time.Time
expires := true
if d == 0 {
d = c.DefaultExpiration
}
if d == -1 {
expires = false
} else {
if d > 0 {
t := time.Now().Add(d)
e = &t
}
c.Items[k] = &Item{
Object: x,
Expires: expires,
Expiration: e,
}
}