diff --git a/VERSION b/VERSION index ccbccc3..c043eea 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.2.0 +2.2.1 diff --git a/app/dependencies.py b/app/dependencies.py index 9480559..b95747d 100644 --- a/app/dependencies.py +++ b/app/dependencies.py @@ -26,23 +26,28 @@ logger = logging.getLogger('discord_app') REDIS_HOST = os.environ.get('REDIS_HOST', 'localhost') REDIS_PORT = int(os.environ.get('REDIS_PORT', '6379')) REDIS_DB = int(os.environ.get('REDIS_DB', '0')) +CACHE_ENABLED = os.environ.get('CACHE_ENABLED', 'true').lower() == 'true' # Initialize Redis client with connection error handling -try: - redis_client = Redis( - host=REDIS_HOST, - port=REDIS_PORT, - db=REDIS_DB, - decode_responses=True, - socket_connect_timeout=5, - socket_timeout=5 - ) - # Test connection - redis_client.ping() - logger.info(f"Redis connected successfully at {REDIS_HOST}:{REDIS_PORT}") -except Exception as e: - logger.warning(f"Redis connection failed: {e}. Caching will be disabled.") +if not CACHE_ENABLED: + logger.info("Caching disabled via CACHE_ENABLED=false") redis_client = None +else: + try: + redis_client = Redis( + host=REDIS_HOST, + port=REDIS_PORT, + db=REDIS_DB, + decode_responses=True, + socket_connect_timeout=5, + socket_timeout=5 + ) + # Test connection + redis_client.ping() + logger.info(f"Redis connected successfully at {REDIS_HOST}:{REDIS_PORT}") + except Exception as e: + logger.warning(f"Redis connection failed: {e}. Caching will be disabled.") + redis_client = None oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token") priv_help = False if not os.environ.get('PRIVATE_IN_SCHEMA') else os.environ.get('PRIVATE_IN_SCHEMA').upper()