Least Frequently Used (LFU) Cache in Pythonic Art

Mohammed Zaheeruddin Malick
1 min readDec 23, 2019

--

Double Maps and a Double Linked List implementation of a classic cache management Algorithm in Python.

Part II of the Holiday Coding Series — Happy Holidays!

Part I (LRU Cache): https://medium.com/@mohammedzu/least-recently-used-lru-cache-in-pythonic-art-bda8a62fce36

A Least Frequently Used Cache (LFU) evicts the least frequently used key, value tuple when the cache is full, to do so the frequency of each key is updated on each access, a map of frequencies pointing to a double linked list keeps track of all items having the same access frequency.

--

--

Mohammed Zaheeruddin Malick
Mohammed Zaheeruddin Malick

Written by Mohammed Zaheeruddin Malick

Tireless Learner | Geek | Father of two budding Women leaders!

No responses yet