I am using the lru_cache from the functools package. I would like to limit the memory that it is allowed to store, so that any data above say 100 MB is not stored.
I was going to define maxsize like so
from functools import lru_cache
cache_limited = lru_cache(maxsize=10_000_000)
However, according to this answer
[maxsize] ... is the number of elements that are stored in the cache.
How can I have a memory-limited cache instead?