@@ -112,9 +112,9 @@ func (c *cache) Replace(k string, x interface{}, d time.Duration) error {
112
112
// whether the key was found.
113
113
func (c * cache ) Get (k string ) (interface {}, bool ) {
114
114
c .mu .RLock ()
115
- // "Inlining" of get
115
+ // "Inlining" of get and expired
116
116
item , found := c .items [k ]
117
- if ! found || item .Expired ( ) {
117
+ if ! found || ( item .Expiration > 0 && time . Now (). UnixNano () > item . Expiration ) {
118
118
c .mu .RUnlock ()
119
119
return nil , false
120
120
}
@@ -124,7 +124,8 @@ func (c *cache) Get(k string) (interface{}, bool) {
124
124
125
125
func (c * cache ) get (k string ) (interface {}, bool ) {
126
126
item , found := c .items [k ]
127
- if ! found || item .Expired () {
127
+ // "Inlining" of expired
128
+ if ! found || (item .Expiration > 0 && time .Now ().UnixNano () > item .Expiration ) {
128
129
return nil , false
129
130
}
130
131
return item .Object , true
@@ -884,7 +885,8 @@ func (c *cache) DeleteExpired() {
884
885
now := time .Now ().UnixNano ()
885
886
c .mu .Lock ()
886
887
for k , v := range c .items {
887
- if v .expired (now ) {
888
+ // "Inlining" of expired
889
+ if v .Expiration > 0 && now > v .Expiration {
888
890
ov , evicted := c .delete (k )
889
891
if evicted {
890
892
evictedItems = append (evictedItems , keyAndValue {k , ov })
0 commit comments