MCPcopy Create free account
hub / github.com/TheSmallHanCat/flow2api / update_cache_config

Method update_cache_config

src/core/database.py:1749–1784  ·  view source on GitHub ↗

Update cache configuration

(self, enabled: bool = None, timeout: int = None, base_url: Optional[str] = None)

Source from the content-addressed store, hash-verified

1747 return CacheConfig(cache_enabled=False, cache_timeout=7200)
1748
1749 async def update_cache_config(self, enabled: bool = None, timeout: int = None, base_url: Optional[str] = None):
1750 """Update cache configuration"""
1751 async with self._connect(write=True) as db:
1752 db.row_factory = aiosqlite.Row
1753 # Get current values
1754 cursor = await db.execute("SELECT * FROM cache_config WHERE id = 1")
1755 row = await cursor.fetchone()
1756
1757 if row:
1758 current = dict(row)
1759 # Use new values if provided, otherwise keep existing
1760 new_enabled = enabled if enabled is not None else current.get("cache_enabled", False)
1761 new_timeout = timeout if timeout is not None else current.get("cache_timeout", 7200)
1762 new_base_url = base_url if base_url is not None else current.get("cache_base_url")
1763
1764 # If base_url is explicitly set to empty string, treat as None
1765 if base_url == "":
1766 new_base_url = None
1767
1768 await db.execute("""
1769 UPDATE cache_config
1770 SET cache_enabled = ?, cache_timeout = ?, cache_base_url = ?, updated_at = CURRENT_TIMESTAMP
1771 WHERE id = 1
1772 """, (new_enabled, new_timeout, new_base_url))
1773 else:
1774 # Insert default row if not exists
1775 new_enabled = enabled if enabled is not None else False
1776 new_timeout = timeout if timeout is not None else 7200
1777 new_base_url = base_url if base_url is not None else None
1778
1779 await db.execute("""
1780 INSERT INTO cache_config (id, cache_enabled, cache_timeout, cache_base_url)
1781 VALUES (1, ?, ?, ?)
1782 """, (new_enabled, new_timeout, new_base_url))
1783
1784 await db.commit()
1785
1786 # Debug config operations
1787 async def get_debug_config(self) -> 'DebugConfig':

Callers 3

update_cache_enabledFunction · 0.80
update_cache_config_fullFunction · 0.80
update_cache_base_urlFunction · 0.80

Calls 1

_connectMethod · 0.95

Tested by

no test coverage detected