feat: implement Redis caching for analytics endpoints with fallback to database
Test / test (push) Successful in 15s
Test / test (push) Successful in 15s
This commit is contained in:
+12
@@ -2,13 +2,25 @@
|
||||
from fastapi import FastAPI
|
||||
|
||||
from app.api.routes import api_router
|
||||
from app.core.cache import init_cache, shutdown_cache
|
||||
from app.core.config import settings
|
||||
from app.core.middleware.cache_monitor import CacheAvailabilityMiddleware
|
||||
|
||||
|
||||
def create_app() -> FastAPI:
|
||||
"""Build FastAPI application instance."""
|
||||
application = FastAPI(title=settings.project_name, version=settings.version)
|
||||
application.include_router(api_router)
|
||||
application.add_middleware(CacheAvailabilityMiddleware)
|
||||
|
||||
@application.on_event("startup")
|
||||
async def _startup() -> None:
|
||||
await init_cache()
|
||||
|
||||
@application.on_event("shutdown")
|
||||
async def _shutdown() -> None:
|
||||
await shutdown_cache()
|
||||
|
||||
return application
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user