vllm.utils.cache
¶
Classes:
-
LRUCache–
LRUCache
¶
Bases: LRUCache[_K, _V]
Methods:
-
peek–Look up a value without copying the cache or updating order or stats.
-
pin–Pins a key in the cache preventing it from being
-
popitem–Remove and return the
(key, value)pair least recently used. -
put_if_fits–Insert
valueif it is not larger than the cache capacity. -
stat–Gets the cumulative number of hits and queries against this cache.
Attributes:
-
cache(Mapping[_K, _V]) –Return the internal cache dictionary in order (read-only).
-
order(Mapping[_K, None]) –Return the internal order dictionary (read-only).
cache
property
¶
Return the internal cache dictionary in order (read-only).
order
property
¶
Return the internal order dictionary (read-only).
_unpin(key)
¶
Unpins a key in the cache allowing it to be evicted in the LRU order.
peek(key, /, default=None)
¶
Look up a value without copying the cache or updating order or stats.
pin(key)
¶
Pins a key in the cache preventing it from being evicted in the LRU order.
popitem(remove_pinned=False)
¶
Remove and return the (key, value) pair least recently used.
put_if_fits(key, value)
¶
Insert value if it is not larger than the cache capacity.
Unlike put, this does not raise when a single item exceeds
maxsize. Size is computed once inside the insert path.
Returns:
-
bool–Trueif the item was cached, otherwiseFalse.
stat(*, delta=False)
¶
Gets the cumulative number of hits and queries against this cache.
If delta=True, instead gets these statistics
since the last call that also passed delta=True.