mirror of
https://github.com/grillazz/fastapi-sqlalchemy-asyncpg.git
synced 2025-08-26 16:40:40 +03:00
Merge pull request #114 from grillazz/sqlalchemy-2
drop redundant lru cache
This commit is contained in:
commit
8134ac4ed3
@ -1,5 +1,4 @@
|
||||
import os
|
||||
from functools import lru_cache
|
||||
|
||||
from pydantic import PostgresDsn, RedisDsn
|
||||
from pydantic_settings import BaseSettings
|
||||
@ -12,9 +11,4 @@ class Settings(BaseSettings):
|
||||
jwt_expire: int = os.getenv("JWT_EXPIRE")
|
||||
|
||||
|
||||
@lru_cache
|
||||
def get_settings():
|
||||
return Settings()
|
||||
|
||||
|
||||
settings = get_settings()
|
||||
settings = Settings()
|
||||
|
@ -3,10 +3,9 @@ from collections.abc import AsyncGenerator
|
||||
from sqlalchemy.ext.asyncio import create_async_engine
|
||||
from sqlalchemy.ext.asyncio import async_sessionmaker
|
||||
|
||||
from app import config
|
||||
from app.config import settings as global_settings
|
||||
from app.utils.logging import AppLogger
|
||||
|
||||
global_settings = config.get_settings()
|
||||
logger = AppLogger.__call__().get_logger()
|
||||
|
||||
engine = create_async_engine(
|
||||
|
@ -8,11 +8,8 @@ from sqlalchemy.dialects.postgresql import UUID
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from sqlalchemy.orm import mapped_column, Mapped
|
||||
|
||||
from app import config
|
||||
from app.models.base import Base
|
||||
|
||||
global_settings = config.get_settings()
|
||||
|
||||
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
|
||||
|
||||
|
||||
|
@ -1,9 +1,6 @@
|
||||
import redis.asyncio as redis
|
||||
|
||||
from app import config
|
||||
|
||||
|
||||
global_settings = config.get_settings()
|
||||
from app.config import settings as global_settings
|
||||
|
||||
|
||||
async def get_redis():
|
||||
|
@ -1,14 +1,12 @@
|
||||
import time
|
||||
import jwt
|
||||
|
||||
from app import config
|
||||
from app.config import settings as global_settings
|
||||
from app.models.user import User
|
||||
|
||||
from fastapi import Request, HTTPException
|
||||
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
|
||||
|
||||
global_settings = config.get_settings()
|
||||
|
||||
|
||||
async def verify_jwt(request: Request, token: str) -> bool:
|
||||
_payload = await request.app.state.redis.get(token)
|
||||
|
Loading…
x
Reference in New Issue
Block a user