mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
feat(backend/llm-registry): wire refresh_runtime_caches to Redis invalidation and pub/sub
After any admin DB mutation, clear the shared Redis cache, refresh this process's in-memory state, then publish a notification so all other workers reload from Redis without hitting the database.
This commit is contained in:
@@ -575,5 +575,14 @@ async def revert_migration(
|
||||
|
||||
|
||||
async def refresh_runtime_caches() -> None:
|
||||
"""Refresh the LLM registry and clear all related caches."""
|
||||
"""Invalidate the shared Redis cache, refresh this process, notify other workers."""
|
||||
from backend.data.llm_registry.notifications import (
|
||||
publish_registry_refresh_notification,
|
||||
)
|
||||
|
||||
# Invalidate Redis so the next fetch hits the DB.
|
||||
llm_registry.clear_registry_cache()
|
||||
# Refresh this process (also repopulates Redis via @cached(shared_cache=True)).
|
||||
await llm_registry.refresh_llm_registry()
|
||||
# Tell other workers to reload their in-process cache from the fresh Redis data.
|
||||
await publish_registry_refresh_notification()
|
||||
|
||||
Reference in New Issue
Block a user