|
mdiep: I don't remember the details of the cache TBH. But cache management is about removing the oldest, least used cache entries. There are tons of algorithms out there for doing so. But before you can even implement one of those you need to know when each item in the cache is used.
I have a faint recollection of there being a "last-used" indicator in each cache entry, such as touching a file when it was last used, etc. That at least gets you the oldest-used items. Maybe that is good enough. You just gather up all of those last-used markers and delete the entries that are the oldest.
But beware of incorrect algorithms. Algorithms based on time alone are usually wrong. i.e. "delete all entries older than xx days". A cache is at it's most effective when it's full. The only reason to remove entries is to make room for new entries. So an algorithm would be "I need to add a new entry, which is yy size big so I need to remove only enough of the oldest entries to free up yy space".
|