From f2c0b41e789dc42049b943d0e93b06c53072783b Mon Sep 17 00:00:00 2001 From: yangdx Date: Tue, 7 Oct 2025 22:57:21 +0800 Subject: [PATCH] Make PostgreSQL statement_cache_size configuration optional MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Remove forced int conversion • Allow None values for cache size • Add conditional parameter setting --- lightrag/kg/postgres_impl.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lightrag/kg/postgres_impl.py b/lightrag/kg/postgres_impl.py index 4e6658b9..50c2108f 100644 --- a/lightrag/kg/postgres_impl.py +++ b/lightrag/kg/postgres_impl.py @@ -77,8 +77,8 @@ class PostgreSQLDB: # Server settings self.server_settings = config.get("server_settings") - # Statement LRU cache size - self.statement_cache_size = int(config.get("statement_cache_size")) + # Statement LRU cache size (keep as-is, allow None for optional configuration) + self.statement_cache_size = config.get("statement_cache_size") if self.user is None or self.password is None or self.database is None: raise ValueError("Missing database user, password, or database") @@ -164,12 +164,16 @@ class PostgreSQLDB: "port": self.port, "min_size": 1, "max_size": self.max, - "statement_cache_size": self.statement_cache_size, } - logger.info( - f"PostgreSQL, statement LRU cache size set as: {self.statement_cache_size}" - ) + # Only add statement_cache_size if it's configured + if self.statement_cache_size is not None: + connection_params["statement_cache_size"] = int( + self.statement_cache_size + ) + logger.info( + f"PostgreSQL, statement LRU cache size set as: {self.statement_cache_size}" + ) # Add SSL configuration if provided ssl_context = self._create_ssl_context()