diff --git a/README.md b/README.md index 50b6890..95727b8 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ This project provides an external logging backend implementation for LMCache. ## Features -- Implements the `StorageBackendInterface` from LMCache +- Implements the `StoragePluginInterface` from LMCache - Logs all backend operations (put, get, prefetch, pin, etc.) - Easy to integrate with existing LMCache systems @@ -22,10 +22,10 @@ Add the following to your LMCache Configuration: chunk_size: 64 local_cpu: False max_local_cpu_size: 5 -external_backends: "log_external_backend" +storage_plugins: "log_external_backend" extra_config: - external_backend.log_external_backend.module_path: lmc_external_log_backend.lmc_external_log_backend - external_backend.log_external_backend.class_name: ExternalLogBackend + storage_plugin.log_external_backend.module_path: lmc_external_log_backend.lmc_external_log_backend + storage_plugin.log_external_backend.class_name: ExternalLogBackend ``` diff --git a/lmc_external_log_backend/lmc_external_log_backend.py b/lmc_external_log_backend/lmc_external_log_backend.py index f622198..b0b17da 100644 --- a/lmc_external_log_backend/lmc_external_log_backend.py +++ b/lmc_external_log_backend/lmc_external_log_backend.py @@ -2,36 +2,30 @@ from typing import List, Optional from concurrent.futures import Future -# Third Party -import torch - # First Party from lmcache.logging import init_logger -from lmcache.v1.storage_backend.abstract_backend import StorageBackendInterface -from lmcache.v1.storage_backend.local_cpu_backend import LocalCPUBackend +from lmcache.v1.storage_backend.abstract_backend import StoragePluginInterface from lmcache.utils import CacheEngineKey from lmcache.v1.memory_management import MemoryObj logger = init_logger(__name__) -class ExternalLogBackend(StorageBackendInterface): +class ExternalLogBackend(StoragePluginInterface): def __init__( self, config, metadata, loop, - memory_allocator, - local_cpu_backend: LocalCPUBackend, + local_cpu_backend, dst_device, - lookup_server=None, ): - super().__init__(dst_device=dst_device) - self.config = config - self.metadata = metadata - self.loop = loop - self.memory_allocator = memory_allocator - self.lookup_server = lookup_server + super().__init__(dst_device=dst_device, + config=config, + metadata = metadata, + local_cpu_backend = local_cpu_backend, + loop = loop, + ) logger.info(f"ExternalLogBackend initialized for device {dst_device}") def contains(self, key: CacheEngineKey, pin: bool = False) -> bool: @@ -78,3 +72,7 @@ def remove(self, key: CacheEngineKey, force: bool = True) -> bool: def close(self) -> None: logger.info("ExternalLogBackend Closing ExternalLogBackend") + + def get_allocator_backend(self): + logger.info(f"ExternalLogBackend get allocator backend: {self.local_cpu_backend}") + return self.local_cpu_backend