perf: stale-while-revalidate cache + startup pre-warm
Docker / docker (push) Successful in 1m58s

If DB has any concerts data (even expired), return it immediately and
refresh in background. Start pre-warming at container startup so the
scrape runs before the first user request.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
dev
2026-05-15 17:02:09 +02:00
parent 09457868e4
commit d3ce89f228
2 changed files with 33 additions and 17 deletions
+2 -1
View File
@@ -11,7 +11,7 @@ from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates
from pydantic import BaseModel
from arte_api import fetch_concerts, get_concerts_by_category, invalidate_cache, CATEGORIES
from arte_api import fetch_concerts, get_all_concerts, get_concerts_by_category, invalidate_cache, CATEGORIES
from downloader import DownloadManager
logging.basicConfig(level=logging.INFO)
@@ -56,6 +56,7 @@ async def lifespan(app: FastAPI):
tasks = [
asyncio.create_task(dm.start_worker()),
asyncio.create_task(_auto_dl_loop()),
asyncio.create_task(get_all_concerts()), # pre-warm cache at startup
]
yield
for t in tasks: