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

Method _load_config_cache

src/storage/sqlite_manager.py:331–352  ·  view source on GitHub ↗

加载配置到内存缓存(仅在初始化时调用一次)

(self)

Source from the content-addressed store, hash-verified

329 # 不抛出异常,允许继续初始化
330
331 async def _load_config_cache(self):
332 """加载配置到内存缓存(仅在初始化时调用一次)"""
333 if self._config_loaded:
334 return
335
336 try:
337 async with aiosqlite.connect(self._db_path) as db:
338 async with db.execute("SELECT key, value FROM config") as cursor:
339 rows = await cursor.fetchall()
340
341 for key, value in rows:
342 try:
343 self._config_cache[key] = json.loads(value)
344 except json.JSONDecodeError:
345 self._config_cache[key] = value
346
347 self._config_loaded = True
348 log.debug(f"Loaded {len(self._config_cache)} config items into cache")
349
350 except Exception as e:
351 log.error(f"Error loading config cache: {e}")
352 self._config_cache = {}
353
354 async def close(self) -> None:
355 """关闭数据库连接"""

Callers 2

initializeMethod · 0.95
reload_config_cacheMethod · 0.95

Calls 3

connectMethod · 0.80
debugMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected