add code for level 4

This commit is contained in:
Матвей
2026-10-08 19:08:55 +03:00
parent b158c88087
commit 13fa322ca2
21 changed files with 390 additions and 27 deletions
+5
View File
@@ -13,6 +13,7 @@ from .errors import ApiError
from .models import ErrorDetails, ErrorResponse
from .config import load_settings
from .routes import router
from .storage.history_cache import HistoryCache
from .storage.postgres import PostgresStore
@@ -35,9 +36,13 @@ async def lifespan(application: FastAPI):
await store.migrate()
application.state.store = store
application.state.settings = settings
cache = HistoryCache(settings.cache_url, settings.cache_ttl_seconds)
await cache.connect()
application.state.history_cache = cache
try:
yield
finally:
await cache.close()
await store.close()