LRU in `lru_cache` refers to eviction policy, that is used when max cache size is reached.
1. When you call a function with specific arguments, the cache first checks if those exact arguments have been used before
2. If yes - there is a cache hit and it returns the cached result from the previous calculation.
3. If no - there is a cache miss and it executes the function, stores the result in cache and returns the result.
4. When the cache reaches its `maxsize` limit, it needs to remove entries to make space for the new ones. It's done by removing the entry that was least recently used.
>[!note]
>Think of it like a bookshelf with a fixed space. If it's full and you want to add a new book to it, first you need to make space for it by removing a book you haven't touched in the longest time.
### See also
1. [[What is lru_cache in Python?]]
2. [[What is a LRU Cache?]]