diff --git a/.env.example b/.env.example index 2f0692ff..008b1c9a 100644 --- a/.env.example +++ b/.env.example @@ -33,4 +33,6 @@ ADMIN_LOGS_CHAT_ID=-1234 # tg chat id for admin logs VK_TOKEN=fppgmdbgonj # ocr -MYSTIC_TOKEN=444 \ No newline at end of file +MYSTIC_TOKEN=444 + +REDIS_MAX_CONNECTIONS=128 diff --git a/src/config.py b/src/config.py index 99b7c37d..56a80509 100644 --- a/src/config.py +++ b/src/config.py @@ -32,6 +32,8 @@ class Config(BaseSettings): MYSTIC_TOKEN: str | None = None + REDIS_MAX_CONNECTIONS: int = 128 + # @model_validator(mode="after") # def validate_sentry_non_local(self) -> "Config": # if self.ENVIRONMENT.is_deployed and not self.SENTRY_DSN: diff --git a/src/redis.py b/src/redis.py index 78011861..e49fbd5a 100644 --- a/src/redis.py +++ b/src/redis.py @@ -8,7 +8,9 @@ from src.models import CustomModel pool = aioredis.ConnectionPool.from_url( - str(settings.REDIS_URL), max_connections=32, decode_responses=True + str(settings.REDIS_URL), + max_connections=settings.REDIS_MAX_CONNECTIONS, + decode_responses=True, ) redis_client = aioredis.Redis(connection_pool=pool) diff --git a/start-polling.py b/start-polling.py index dfa15433..3184a05a 100644 --- a/start-polling.py +++ b/start-polling.py @@ -16,7 +16,9 @@ if __name__ == "__main__": pool = aioredis.ConnectionPool.from_url( - str(settings.REDIS_URL), max_connections=10, decode_responses=True + str(settings.REDIS_URL), + max_connections=settings.REDIS_MAX_CONNECTIONS, + decode_responses=True ) redis.redis_client = aioredis.Redis(connection_pool=pool)