LRUCache | R Documentation |
LRU caches remove items in a FIFO manner, such that the oldest items to be used are the first to be removed. If you attempt to retrieve a cache item that is older than the expiration time, the item will be invalidated.
Element
Class describes the values in the cache
new()
Initialize an “LRUCache“ instance.
LRUCache$new(max_cache_items, expiration_horizon, retrieval_function)
max_cache_items
(int): Maximum number of items to store in cache.
expiration_horizon
(datetime.timedelta): Maximum time duration a cache element can persist before being invalidated.
retrieval_function
(Callable[[KeyType, ValType], ValType]): Function which maps cache keys and current values to new values. This function must have kwarg arguments “key“ and “value“. This function is called as a fallback when the key is not found in the cache, or a key has expired.
clear()
Deletes all elements from the cache.
LRUCache$clear()
get()
Returns value corresponding to key in cache.
LRUCache$get(key, data_source_fallback = TRUE)
key
(KeyType): Key in cache to retrieve.
data_source_fallback
(Optional[bool]): True if data should be retrieved if it's stale or not in cache. Default: True.
put()
Adds key to cache using “retrieval_function“. If value is provided, this is used instead. If the key is already in cache, the old element is removed. If the cache size exceeds the size limit, old elements are removed in order to meet the limit.
LRUCache$put(key, value = NULL)
key
(KeyType): Key in cache to retrieve.
value
(Optional[ValType]): Value to store for key. Default: None.
clone()
The objects of this class are cloneable with this method.
LRUCache$clone(deep = FALSE)
deep
Whether to make a deep clone.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.