LMCache Backend Interface#
- class StorageBackendInterface(dst_device: str = 'cuda')[source]#
-
- abstract exists_in_put_tasks(key: CacheEngineKey) bool [source]#
Check whether key is in the ongoing put tasks.
- abstract get_blocking(key: CacheEngineKey) MemoryObj | None [source]#
A blcocking function to get the kv cache from the storage backend.
- Parameters:
key (CacheEngineKey) – The key of the MemoryObj.
- Returns:
MemoryObj. None if the key does not exist.
- class StorageManager(config: LMCacheEngineConfig, metadata: LMCacheEngineMetadata, allocator: MemoryAllocatorInterface, lookup_server: LookupServerInterface | None = None)[source]#
The StorageManager is responsible for managing the storage backends.
- allocate(shape: Size, dtype: dtype, eviction=True) MemoryObj | None [source]#
Allocate memory object with memory allocator. Use LRU evictor if eviction is enabled.
- contains(key: CacheEngineKey, search_range: List[str] | None = None) bool [source]#
Check whether the key exists in the storage backend.
- Parameters:
key (CacheEngineKey) – The key to check.
search_range (Optional[List[str]]) – The range of storage backends
to search in. Should be a subset of [“Hot”, “LocalDiskBackend”] for now. If None, search in all backends.
return: True if the key exists in the specified storage backends.
- get(key: CacheEngineKey) MemoryObj | None [source]#
Blocking function to get the memory object from the storages.