lru cache
1.0.0A least-recently-used cache structure
About
This is an implementation of a least-recently-used cache datastructure, useful for tracking a limited set of resource allocations with minimal evictions.
See lru-cache
, make-lru-cache
, etc.
System Information
Definition Index
-
ORG.SHIRAKUMO.LRU-CACHE
No documentation provided.-
EXTERNAL STRUCTURE LRU-CACHE
A least-recently-used cache datastructure. See MAKE-LRU-CACHE See LRU-CACHE-SIZE See LRU-CACHE-PUSH See LRU-CACHE-POP See LRU-CACHE-ID See LRU-CACHE-EVICT See LRU-CACHE-CLEAR See LRU-CACHE-COUNT See MAP-LRU-CACHE See DO-LRU-CACHE
-
EXTERNAL FUNCTION LRU-CACHE-CLEAR
- CACHE
Evicts all elements in the cache and clears it. This operation is O(n). See LRU-CACHE
-
EXTERNAL FUNCTION LRU-CACHE-COUNT
- CACHE
Counts the number of elements currently in the cache. This operation is O(n). See LRU-CACHE See LRU-CACHE-SIZE
-
EXTERNAL FUNCTION LRU-CACHE-EVICT
- CACHE
Evicts the least recently used element from the cache. Returns the element and the ID of the evicted node, if any. This operation is O(n). See LRU-CACHE
-
EXTERNAL FUNCTION LRU-CACHE-ID
- VALUE
- CACHE
Returns the ID of the node the element is in. If the element is not in the cache, NIL is returned. This operation is O(1). See LRU-CACHE
-
EXTERNAL FUNCTION LRU-CACHE-POP
- VALUE
- CACHE
Pops an element out of the cache. If the element exists in the cache, the ID of the node is returned. If the element did not exist in the cache, NIL is returned. This operation is O(1). See LRU-CACHE See LRU-CACHE-PUSH
-
EXTERNAL FUNCTION LRU-CACHE-PUSH
- VALUE
- CACHE
Pushes an element to the cache. The element is put into the cache as the most recently used. If the element did not exist before and the cache is already full, the least recently used element is evicted. Returns the ID of the node the element was put into, if it was not already in the cache. If the element was already in the cache, NIL is returned. This operation is O(1). See LRU-CACHE See LRU-CACHE-POP
-
EXTERNAL FUNCTION LRU-CACHE-SIZE
- INSTANCE
Returns the size of the cache. This operation is O(1). See LRU-CACHE
-
EXTERNAL FUNCTION MAKE-LRU-CACHE
- SIZE
- &OPTIONAL
- TEST
Create a new LRU-CACHE instance that can hold SIZE elements. The TEST may be one of the arguments acceptable as the TEST of a hash-table. See CL:HASH-TABLE-TEST See LRU-CACHE
-
EXTERNAL FUNCTION MAP-LRU-CACHE
- FUNCTION
- CACHE
Iterates over the cached elements in order from most recent to least recent. Calls FUNCTION with two values: the element and the ID of the node the element occupies. Note that the ID does *not* necessarily correspond to the index of the node in the cache sequence. Returns the CACHE instance. See LRU-CACHE See DO-LRU-CACHE
-
EXTERNAL MACRO DO-LRU-CACHE
- ELEMENT
- ID
- CACHE
- &OPTIONAL
- RESULT
- &BODY
- BODY
Convenience macro to iterate over the cached elements in order from most recent to least recent. An implicit NIL block is bound around BODY. If BODY does not explicitly return, RESULT is evaluated and returned instead. See LRU-CACHE See MAP-LRU-CACHE
-
EXTERNAL SOURCE-TRANSFORM LRU-CACHE-SIZE
No documentation provided. -
EXTERNAL SOURCE-TRANSFORM (SETF LRU-CACHE-SIZE)
No documentation provided.
-