refactor: improve code readability by formatting arguments across multiple files
Test / test (push) Successful in 15s
Test / test (push) Successful in 15s
This commit is contained in:
+11
-3
@@ -46,7 +46,9 @@ class RedisCacheManager:
|
||||
if self._client is not None:
|
||||
return
|
||||
self._client = redis.from_url(
|
||||
settings.redis_url, encoding="utf-8", decode_responses=False,
|
||||
settings.redis_url,
|
||||
encoding="utf-8",
|
||||
decode_responses=False,
|
||||
)
|
||||
await self._refresh_availability()
|
||||
|
||||
@@ -63,7 +65,9 @@ class RedisCacheManager:
|
||||
async with self._lock:
|
||||
if self._client is None:
|
||||
self._client = redis.from_url(
|
||||
settings.redis_url, encoding="utf-8", decode_responses=False,
|
||||
settings.redis_url,
|
||||
encoding="utf-8",
|
||||
decode_responses=False,
|
||||
)
|
||||
await self._refresh_availability()
|
||||
|
||||
@@ -127,7 +131,11 @@ async def read_json(client: Redis, key: str) -> Any | None:
|
||||
|
||||
|
||||
async def write_json(
|
||||
client: Redis, key: str, value: Any, ttl_seconds: int, backoff_ms: int,
|
||||
client: Redis,
|
||||
key: str,
|
||||
value: Any,
|
||||
ttl_seconds: int,
|
||||
backoff_ms: int,
|
||||
) -> None:
|
||||
"""Serialize data to JSON and store it with TTL using retry/backoff."""
|
||||
payload = json.dumps(value, separators=(",", ":"), ensure_ascii=True).encode("utf-8")
|
||||
|
||||
+5
-2
@@ -17,7 +17,8 @@ class Settings(BaseSettings):
|
||||
db_name: str = Field(default="test_task_crm", description="Database name")
|
||||
db_user: str = Field(default="postgres", description="Database user")
|
||||
db_password: SecretStr = Field(
|
||||
default=SecretStr("postgres"), description="Database user password",
|
||||
default=SecretStr("postgres"),
|
||||
description="Database user password",
|
||||
)
|
||||
database_url_override: str | None = Field(
|
||||
default=None,
|
||||
@@ -32,7 +33,9 @@ class Settings(BaseSettings):
|
||||
redis_enabled: bool = Field(default=False, description="Toggle Redis-backed cache usage")
|
||||
redis_url: str = Field(default="redis://localhost:6379/0", description="Redis connection URL")
|
||||
analytics_cache_ttl_seconds: int = Field(
|
||||
default=120, ge=1, description="TTL for cached analytics responses",
|
||||
default=120,
|
||||
ge=1,
|
||||
description="TTL for cached analytics responses",
|
||||
)
|
||||
analytics_cache_backoff_ms: int = Field(
|
||||
default=200,
|
||||
|
||||
Reference in New Issue
Block a user