mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-04-28 03:30:23 +00:00
enable api caching
enable websocket and api caching params
This commit is contained in:
parent
9390ba9624
commit
fb02b5f4cc
2 changed files with 5 additions and 19 deletions
|
|
@ -24,7 +24,7 @@ from helpers import files, cache
|
|||
ThreadLockType = Union[threading.Lock, threading.RLock]
|
||||
|
||||
CACHE_AREA = "api_handlers(api)"
|
||||
cache.toggle_area(CACHE_AREA, False) # cache off for now
|
||||
# cache.toggle_area(CACHE_AREA, False) # cache off for now
|
||||
|
||||
Input = dict
|
||||
Output = Union[Dict[str, Any], Response]
|
||||
|
|
@ -236,10 +236,13 @@ def register_api_route(app: Flask, lock: ThreadLockType) -> None:
|
|||
|
||||
def register_watchdogs():
|
||||
from helpers import watchdog
|
||||
from helpers.ws import CACHE_AREA as WS_CACHE_AREA
|
||||
|
||||
|
||||
def on_api_change(items: list[watchdog.WatchItem]):
|
||||
PrintStyle.debug("API endpoint watchdog triggered:", items)
|
||||
cache.clear(CACHE_AREA)
|
||||
cache.clear(WS_CACHE_AREA)
|
||||
|
||||
watchdog.add_watchdog(
|
||||
"api_handlers",
|
||||
|
|
@ -250,20 +253,3 @@ def register_watchdogs():
|
|||
patterns=["*.py"],
|
||||
handler=on_api_change,
|
||||
)
|
||||
|
||||
# WS handler cache shares the same watched directories (api/, usr/api/)
|
||||
from helpers.ws import CACHE_AREA as WS_CACHE_AREA
|
||||
|
||||
def on_ws_change(items: list[watchdog.WatchItem]):
|
||||
PrintStyle.debug("WS handler watchdog triggered:", items)
|
||||
cache.clear(WS_CACHE_AREA)
|
||||
|
||||
watchdog.add_watchdog(
|
||||
"ws_handlers",
|
||||
roots=[
|
||||
files.get_abs_path(files.API_DIR),
|
||||
files.get_abs_path(files.USER_DIR, files.API_DIR),
|
||||
],
|
||||
patterns=["ws_*.py"],
|
||||
handler=on_ws_change,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ ThreadLockType = Union[threading.Lock, threading.RLock]
|
|||
|
||||
NAMESPACE = "/ws"
|
||||
CACHE_AREA = "ws_handlers(api)(plugins)"
|
||||
cache.toggle_area(CACHE_AREA, False) # cache off for now
|
||||
# cache.toggle_area(CACHE_AREA, False) # cache off for now
|
||||
|
||||
|
||||
@dataclass
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue