MCPcopy Create free account
hub / github.com/su-kaka/gcli2api / _load_config_cache

Method _load_config_cache

src/storage/psql_manager.py:201–221  ·  view source on GitHub ↗

加载配置到内存缓存

(self)

Source from the content-addressed store, hash-verified

199 log.error(f"Error ensuring schema compatibility: {e}")
200
201 async def _load_config_cache(self) -> None:
202 """加载配置到内存缓存"""
203 if self._config_loaded:
204 return
205
206 try:
207 async with self._pool.acquire() as conn:
208 rows = await conn.fetch("SELECT key, value FROM config")
209
210 for row in rows:
211 try:
212 self._config_cache[row["key"]] = json.loads(row["value"])
213 except json.JSONDecodeError:
214 self._config_cache[row["key"]] = row["value"]
215
216 self._config_loaded = True
217 log.debug(f"Loaded {len(self._config_cache)} config items into cache")
218
219 except Exception as e:
220 log.error(f"Error loading config cache: {e}")
221 self._config_cache = {}
222
223 async def close(self) -> None:
224 """关闭数据库连接池"""

Callers 2

initializeMethod · 0.95
reload_config_cacheMethod · 0.95

Calls 2

debugMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected