File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed
Expand file tree Collapse file tree 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) {
132132}
133133
134134// Clear all items from the cache.
135- // This reallocate the inderlying array holding the items,
135+ // This reallocates the underlying array holding the items,
136136// so that the memory used by the items is reclaimed.
137137func (c * cache ) Clear () {
138138 c .mu .Lock ()
@@ -163,11 +163,10 @@ func (c *cache) HasExpired(key string) bool {
163163func (c * cache ) SetExpiration (key string , expiration time.Duration ) {
164164 c .mu .Lock ()
165165 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
169169 }
170- item .Expiration = time .Now ().Add (expiration ).UnixNano ()
171170 c .mu .Unlock ()
172171}
173172
You can’t perform that action at this time.
0 commit comments