Update Redis client-side cache configuration to disable by default and add compatibility check for hiredis parser

pull/19529/head
Eric-Guo 1 year ago
parent b00f94df64
commit ad22f4cf78

@ -90,6 +90,6 @@ class RedisConfig(BaseSettings):
) )
REDIS_ENABLE_CLIENT_SIDE_CACHE: bool = Field( REDIS_ENABLE_CLIENT_SIDE_CACHE: bool = Field(
description="Enable client side cache in redis", description="Enable client side cache in redis. Note: Currently not compatible with hiredis parser.",
default=True, default=False,
) )

@ -53,7 +53,14 @@ def init_app(app: DifyApp):
if dify_config.REDIS_USE_SSL: if dify_config.REDIS_USE_SSL:
connection_class = SSLConnection connection_class = SSLConnection
resp_protocol = dify_config.REDIS_SERIALIZATION_PROTOCOL resp_protocol = dify_config.REDIS_SERIALIZATION_PROTOCOL
if dify_config.REDIS_ENABLE_CLIENT_SIDE_CACHE:
# Check if hiredis is available
import importlib
hiredis_available = importlib.util.find_spec("hiredis") is not None
# Disable client-side caching if hiredis is available due to compatibility issues
if dify_config.REDIS_ENABLE_CLIENT_SIDE_CACHE and not hiredis_available:
if resp_protocol >= 3: if resp_protocol >= 3:
clientside_cache_config = CacheConfig() clientside_cache_config = CacheConfig()
else: else:

Loading…
Cancel
Save