"examples/pytorch/vscode:/vscode.git/clone" did not exist on "4ec8f204dd8ff7044818db3493ce898dc945aa72"
Unverified Commit 41628dc1 authored by Teng Ma's avatar Teng Ma Committed by GitHub
Browse files

[HiCache] fix: check clear() method for storage backend (#10096)


Co-authored-by: default avatarhzh0425 <hzh0425@apache.org>
parent a12061df
......@@ -134,11 +134,24 @@ class HiRadixCache(RadixCache):
height += 1
return height
def clear_storage_backend(self):
def clear_storage_backend(self) -> bool:
if self.enable_storage:
self.cache_controller.storage_backend.clear()
logger.info("Hierarchical cache storage backend cleared successfully!")
return True
try:
# Check if the storage backend has a clear method (for nixl backends)
if hasattr(self.cache_controller.storage_backend, "clear"):
self.cache_controller.storage_backend.clear()
logger.info(
"Hierarchical cache storage backend cleared successfully!"
)
return True
else:
logger.warning(
f"Storage backend {type(self.cache_controller.storage_backend).__name__} does not support clear operation."
)
return False
except Exception as e:
logger.error(f"Failed to clear hierarchical cache storage backend: {e}")
return False
else:
logger.warning("Hierarchical cache storage backend is not enabled.")
return False
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment