LRUCache(K, V)
LRU cache (Least Recently Used).
LRUCache supports lifecycle, a global item size limit
and an expiration time can be set for each item.
If a max_size is defined, the LRU cache can only contain max_size items. Beyond max_size, items are deleted from the oldest to the most recently used.
Constructors
Instance methods
Adds an item in the cache. If key exists, this methods raises a KeyError exception.
Adds a value in the cache. If key exists, this methods raises a KeyError exception.
Deletes an item from the cache.
Returns the deleted item or nil.
Checks if the cache has an item by its key. This method checks the item expiration but does not consider the item to be used (the order in the LRU cache is inchanged).
Returns the Hash containing all items.
The Hash can be handled normally without affecting the behavior of
the LRU cache.
Given that the LRU cache purge the items least-recently-used, this method touches an item to consider it as recent use. This makes it possible to up an old element. If the item does not exist, nothing happens.
Returns true if the existing item has been touched,
false if not (because does not exist).