|
|
@ -134,12 +134,14 @@ func (r *Intelligent) Set(key string, value interface{}) { |
|
|
|
|
|
|
|
|
|
|
|
// Delete deletes a given key if exists
|
|
|
|
// Delete deletes a given key if exists
|
|
|
|
func (r *Intelligent) Delete(key string) { |
|
|
|
func (r *Intelligent) Delete(key string) { |
|
|
|
r.currentSize -= uint64(len(r.items[key].([]byte))) |
|
|
|
if _, ok := r.items[key]; ok { |
|
|
|
delete(r.items, key) |
|
|
|
r.currentSize -= uint64(len(r.items[key].([]byte))) |
|
|
|
delete(r.updatedAt, key) |
|
|
|
delete(r.items, key) |
|
|
|
r.totalEvicted++ |
|
|
|
delete(r.updatedAt, key) |
|
|
|
if r.OnEvicted != nil { |
|
|
|
r.totalEvicted++ |
|
|
|
r.OnEvicted(key) |
|
|
|
if r.OnEvicted != nil { |
|
|
|
|
|
|
|
r.OnEvicted(key) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|