From da356940530e01e4bc412650321141d7e75cf020 Mon Sep 17 00:00:00 2001 From: Yongtao Huang <99629139+hyongtao-db@users.noreply.github.com> Date: Tue, 8 Jul 2025 10:39:31 +0800 Subject: [PATCH] Remove unused file lru_cache.py The LRUCache class originated in Dify v0.4, while later code primarily uses `from cachetools import LRUCache`. --- api/core/helper/lru_cache.py | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 api/core/helper/lru_cache.py diff --git a/api/core/helper/lru_cache.py b/api/core/helper/lru_cache.py deleted file mode 100644 index 81501d2e4e..0000000000 --- a/api/core/helper/lru_cache.py +++ /dev/null @@ -1,22 +0,0 @@ -from collections import OrderedDict -from typing import Any - - -class LRUCache: - def __init__(self, capacity: int): - self.cache: OrderedDict[Any, Any] = OrderedDict() - self.capacity = capacity - - def get(self, key: Any) -> Any: - if key not in self.cache: - return None - else: - self.cache.move_to_end(key) # move the key to the end of the OrderedDict - return self.cache[key] - - def put(self, key: Any, value: Any) -> None: - if key in self.cache: - self.cache.move_to_end(key) - self.cache[key] = value - if len(self.cache) > self.capacity: - self.cache.popitem(last=False) # pop the first item