Merge pull request #575 from fkautz/pr_out_fixing_panic_in_intelligent_attempted_to_delete_nonexistent_key

master
Frederick F. Kautz IV 10 years ago
commit 0266ec4bf6
  1. 2
      pkg/storage/drivers/memory/memory_intelligent.go

@ -134,6 +134,7 @@ 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) {
if _, ok := r.items[key]; ok {
r.currentSize -= uint64(len(r.items[key].([]byte))) r.currentSize -= uint64(len(r.items[key].([]byte)))
delete(r.items, key) delete(r.items, key)
delete(r.updatedAt, key) delete(r.updatedAt, key)
@ -141,6 +142,7 @@ func (r *Intelligent) Delete(key string) {
if r.OnEvicted != nil { if r.OnEvicted != nil {
r.OnEvicted(key) r.OnEvicted(key)
} }
}
} }
func (r *Intelligent) isValid(key string) bool { func (r *Intelligent) isValid(key string) bool {

Loading…
Cancel
Save