How to implement a Least Frequently Used (LFU) cache?

后端 未结 7 1451
孤城傲影
孤城傲影 2021-01-31 04:50

Least Frequently Used (LFU) is a type of cache algorithm used to manage memory within a computer. The standard characteristics of this method involve the system keeping track of

7条回答
  •  别那么骄傲
    2021-01-31 05:29

    How about a priority queue? You can keep elements sorted there with keys representing the frequency. Just update the object position in the queue after visiting it. You can update just from time to time for optimizing the performance (but reducing precision).

提交回复
热议问题