From eb8996dd8171beea712513679a356d84ee0567ec Mon Sep 17 00:00:00 2001 From: hajdul88 <52442977+hajdul88@users.noreply.github.com> Date: Thu, 15 Jan 2026 11:08:30 +0100 Subject: [PATCH] feat: extends CacheDBInterface base class with the logging related methods --- .../databases/cache/cache_db_interface.py | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/cognee/infrastructure/databases/cache/cache_db_interface.py b/cognee/infrastructure/databases/cache/cache_db_interface.py index 801e86188..97782aa7c 100644 --- a/cognee/infrastructure/databases/cache/cache_db_interface.py +++ b/cognee/infrastructure/databases/cache/cache_db_interface.py @@ -77,3 +77,37 @@ class CacheDBInterface(ABC): Gracefully close any async connections. """ pass + + @abstractmethod + async def log_usage( + self, + user_id: str, + log_entry: dict, + ttl: int | None = 604800, + ): + """ + Log usage information (API endpoint calls, MCP tool invocations) to cache. + + Args: + user_id: The user ID. + log_entry: Dictionary containing usage log information. + ttl: Optional time-to-live (seconds). If provided, the log list expires after this time. + + Raises: + CacheConnectionError: If cache connection fails or times out. + """ + pass + + @abstractmethod + async def get_usage_logs(self, user_id: str, limit: int = 100): + """ + Retrieve usage logs for a given user. + + Args: + user_id: The user ID. + limit: Maximum number of logs to retrieve (default: 100). + + Returns: + List of usage log entries, most recent first. + """ + pass