File tree 1 file changed +4
-5
lines changed
1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -132,7 +132,7 @@ func (c *cache) Delete(key string) {
132
132
}
133
133
134
134
// Clear all items from the cache.
135
- // This reallocate the inderlying array holding the items,
135
+ // This reallocates the underlying array holding the items,
136
136
// so that the memory used by the items is reclaimed.
137
137
func (c * cache ) Clear () {
138
138
c .mu .Lock ()
@@ -163,11 +163,10 @@ func (c *cache) HasExpired(key string) bool {
163
163
func (c * cache ) SetExpiration (key string , expiration time.Duration ) {
164
164
c .mu .Lock ()
165
165
item , ok := c .Items [key ]
166
- if ! ok {
167
- c . mu . Unlock ()
168
- return
166
+ if ok {
167
+ item . Expiration = time . Now (). Add ( expiration ). UnixNano ()
168
+ c . Items [ key ] = item
169
169
}
170
- item .Expiration = time .Now ().Add (expiration ).UnixNano ()
171
170
c .mu .Unlock ()
172
171
}
173
172
You can’t perform that action at this time.
0 commit comments