You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now that the cache is filled, the next call to Cache.Set should lead to the eviction of the Least-Frequently-Used entry. So far, so good.
When multiple entries share the same frequency (here all our entries have freq=0) we "pick" one at random. That is, the Cache.evict internal function will iterate over the internal map until we have evicted enough entries. Iterating over a map is done in a randomized order (per Golang maps semantics). We should explore whether that's a desirable behavior or if we should evict the least recent entry when everything else is equal.
Potential solution: Use a sorted map for the internal LFU maps.
The text was updated successfully, but these errors were encountered:
Consider an LFU cache with
capacity=10
i.e:We fill the cache:
Now that the cache is filled, the next call to
Cache.Set
should lead to the eviction of the Least-Frequently-Used entry. So far, so good.When multiple entries share the same frequency (here all our entries have freq=0) we "pick" one at random. That is, the
Cache.evict
internal function will iterate over the internal map until we have evicted enough entries. Iterating over a map is done in a randomized order (per Golang maps semantics). We should explore whether that's a desirable behavior or if we should evict the least recent entry when everything else is equal.Potential solution: Use a sorted map for the internal LFU maps.
The text was updated successfully, but these errors were encountered: