mru

How to implement a most-recently-used cache

萝らか妹 提交于 2019-11-29 02:42:02
问题 What would be the best way to implement a most-recently-used cache of objects? Here are the requirements and restrictions... Objects are stored as key/value Object/Object pairs, so the interface would be a bit like Hashtable get/put A call to 'get' would mark that object as the most recently used. At any time, the least recently used object can be purged from the cache. Lookups and purges must be fast (As in Hashtable fast) The number of Objects may be large, so list lookups are not good