add REDIS_ENABLE_CLIENT_SIDE_CACHE config

pull/19493/head
Bowen Liang 1 year ago
parent 22cbc9f035
commit f7b5053f31

@ -88,3 +88,8 @@ class RedisConfig(BaseSettings):
description="Redis serialization protocol (RESP) version", description="Redis serialization protocol (RESP) version",
default=3, default=3,
) )
REDIS_ENABLE_CLIENT_SIDE_CACHE: bool = Field(
description="Enable client side cache in redis",
default=True,
)

@ -53,7 +53,13 @@ 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
clientside_cache_config = CacheConfig() if resp_protocol >= 3 else None if dify_config.REDIS_ENABLE_CLIENT_SIDE_CACHE:
if resp_protocol >= 3:
clientside_cache_config = CacheConfig()
else:
raise ValueError("Client side cache is only supported in RESP3")
else:
clientside_cache_config = None
redis_params: dict[str, Any] = { redis_params: dict[str, Any] = {
"username": dify_config.REDIS_USERNAME, "username": dify_config.REDIS_USERNAME,

Loading…
Cancel
Save