We're updating the issue view to help you get more done. 

Overwriting entries in LRU-cache deletes LRU key-values unnecessarily

Description

To "overwrite" the value in an LRUCache, one uses assoc. Surprisingly, another k,v entry is evicted, even though the total number of items in the cache should not be increased by overwriting.

Demo:

(def C0 (lru-cache-factory {} :threshold 3))
; --> #<Var@7ec74910: {}>

(def C1 (-> C0 (assoc :a 1) (assoc :b 2) (assoc :c 3)))
; --> #<Var@315863e4: {:c 3, :b 2, :a 1}>

(-> C1 (assoc :a 4) (assoc :a 5) (assoc :a 6))
; --> {:a 6}

Environment

None

Status

Assignee

Fogus

Reporter

import

Labels

None

Approval

None

Patch

None

Priority

Major