Skip to content

Commit 614c27c

Browse files
beastoinclaude
andauthored
H64ee redis (#4223)
* Added memory cache support to get_available_apps function * Add memory cache initialization to pusher service Initialize memory cache managers on startup and shutdown gracefully, following the same pattern as the main backend service. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 8f206eb commit 614c27c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

backend/pusher/main.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from fastapi import FastAPI
66

77
from routers import pusher
8+
from database.cache import init_cache, shutdown_cache
89

910
if os.environ.get('SERVICE_ACCOUNT_JSON'):
1011
service_account_info = json.loads(os.environ["SERVICE_ACCOUNT_JSON"])
@@ -25,3 +26,21 @@
2526
@app.get('/health')
2627
def health_check():
2728
return {"status": "healthy"}
29+
30+
31+
@app.on_event("startup")
32+
async def startup_event():
33+
"""Initialize cache managers on startup."""
34+
try:
35+
init_cache(max_memory_mb=100)
36+
print("Cache managers initialized successfully")
37+
except Exception as e:
38+
print(f"Failed to initialize cache managers: {e}")
39+
# Continue startup even if cache managers fail
40+
41+
42+
@app.on_event("shutdown")
43+
async def shutdown_event():
44+
"""Stop cache managers on shutdown."""
45+
shutdown_cache()
46+
print("Cache managers stopped")

0 commit comments

Comments
 (0)