mirror of
https://github.com/flibusta-apps/book_library_server.git
synced 2025-12-06 15:15:36 +01:00
Add search result cache
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
from operator import add
|
||||
from fastapi import FastAPI
|
||||
from fastapi_pagination import add_pagination
|
||||
import aioredis
|
||||
|
||||
from core.db import database
|
||||
from core.config import env_config
|
||||
|
||||
from app.views import routers
|
||||
|
||||
|
||||
@@ -11,6 +13,13 @@ def start_app() -> FastAPI:
|
||||
|
||||
app.state.database = database
|
||||
|
||||
app.state.redis = aioredis.Redis(
|
||||
host=env_config.REDIS_HOST,
|
||||
port=env_config.REDIS_PORT,
|
||||
db=env_config.REDIS_DB,
|
||||
password=env_config.REDIS_PASSWORD,
|
||||
)
|
||||
|
||||
for router in routers:
|
||||
app.include_router(router)
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseSettings
|
||||
|
||||
|
||||
@@ -10,6 +12,11 @@ class EnvConfig(BaseSettings):
|
||||
POSTGRES_PORT: int
|
||||
POSTGRES_DB: str
|
||||
|
||||
REDIS_HOST: str
|
||||
REDIS_PORT: int
|
||||
REDIS_DB: int
|
||||
REDIS_PASSWORD: Optional[str]
|
||||
|
||||
class Config:
|
||||
env_file = '.env'
|
||||
env_file_encoding = 'utf-8'
|
||||
|
||||
Reference in New Issue
Block a user