enable api caching
enable websocket and api caching params
frdel committed
Mar 30, 2026 at 17:15 UTC
fb02b5f4cc510a05a5cee92077a90505fb37bfd6
2 files changed
+5
-19
helpers/api.py
+4
-18
@@ -24,7 +24,7 @@ from helpers import files, cache
24
ThreadLockType = Union[threading.Lock, threading.RLock]
25
26
CACHE_AREA = "api_handlers(api)"
27
-cache.toggle_area(CACHE_AREA, False) # cache off for now
27
+# cache.toggle_area(CACHE_AREA, False) # cache off for now
28
29
Input = dict
30
Output = Union[Dict[str, Any], Response]
@@ -236,10 +236,13 @@ def register_api_route(app: Flask, lock: ThreadLockType) -> None:
236
237
def register_watchdogs():
238
from helpers import watchdog
239
+ from helpers.ws import CACHE_AREA as WS_CACHE_AREA
240
+
241
242
def on_api_change(items: list[watchdog.WatchItem]):
243
PrintStyle.debug("API endpoint watchdog triggered:", items)
244
cache.clear(CACHE_AREA)
245
+ cache.clear(WS_CACHE_AREA)
246
247
watchdog.add_watchdog(
248
"api_handlers",
@@ -250,20 +253,3 @@ def register_watchdogs():
253
patterns=["*.py"],
254
handler=on_api_change,
255
)
253
-
254
- # WS handler cache shares the same watched directories (api/, usr/api/)
255
- from helpers.ws import CACHE_AREA as WS_CACHE_AREA
256
-
257
- def on_ws_change(items: list[watchdog.WatchItem]):
258
- PrintStyle.debug("WS handler watchdog triggered:", items)
259
- cache.clear(WS_CACHE_AREA)
260
-
261
- watchdog.add_watchdog(
262
- "ws_handlers",
263
- roots=[
264
- files.get_abs_path(files.API_DIR),
265
- files.get_abs_path(files.USER_DIR, files.API_DIR),
266
- ],
267
- patterns=["ws_*.py"],
268
- handler=on_ws_change,
269
- )
helpers/ws.py
+1
-1
@@ -159,7 +159,7 @@ ThreadLockType = Union[threading.Lock, threading.RLock]
159
160
NAMESPACE = "/ws"
161
CACHE_AREA = "ws_handlers(api)(plugins)"
162
-cache.toggle_area(CACHE_AREA, False) # cache off for now
162
+# cache.toggle_area(CACHE_AREA, False) # cache off for now
163
164
165
@dataclass