remove old import
This commit is contained in:
@@ -12,10 +12,11 @@ from typing import Any, Optional
|
||||
|
||||
try:
|
||||
import redis.asyncio as redis # type: ignore
|
||||
except Exception: # pragma: no cover - allow running without redis installed
|
||||
except ImportError: # pragma: no cover - allow running without redis installed
|
||||
redis = None # type: ignore
|
||||
|
||||
from app.config import settings
|
||||
from app.utils.logging import app_logger
|
||||
|
||||
|
||||
_client: Optional["redis.Redis"] = None # type: ignore
|
||||
@@ -35,14 +36,15 @@ async def _get_client() -> Optional["redis.Redis"]: # type: ignore
|
||||
if _client is None:
|
||||
try:
|
||||
_client = redis.from_url(settings.redis_url, decode_responses=True) # type: ignore
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
app_logger.debug(f"Redis connection failed: {str(e)}")
|
||||
_client = None
|
||||
return _client
|
||||
|
||||
|
||||
def _stable_hash(obj: Any) -> str:
|
||||
data = json.dumps(obj, sort_keys=True, separators=(",", ":"))
|
||||
return hashlib.sha1(data.encode("utf-8")).hexdigest()
|
||||
return hashlib.sha256(data.encode("utf-8")).hexdigest()
|
||||
|
||||
|
||||
def build_key(kind: str, user_id: Optional[str], parts: dict) -> str:
|
||||
|
||||
Reference in New Issue
Block a user