@@ -43,12 +43,12 @@ class RedisClientWrapper:
4343 if the client is not initialized.
4444 """
4545
46- _client : Union [redis .Redis , RedisCluster , None ]
46+ _client : Union [redis .Redis , RedisCluster , Any , None ]
4747
4848 def __init__ (self ) -> None :
4949 self ._client = None
5050
51- def initialize (self , client : Union [redis .Redis , RedisCluster ]) -> None :
51+ def initialize (self , client : Union [redis .Redis , RedisCluster , Any ]) -> None :
5252 if self ._client is None :
5353 self ._client = client
5454
@@ -253,25 +253,6 @@ def _create_standalone_client(redis_params: dict[str, Any]) -> Union[redis.Redis
253253 return client
254254
255255
256- def init_app (app : DifyApp ):
257- """Initialize Redis client and attach it to the app."""
258- global redis_client
259-
260- # Determine Redis mode and create appropriate client
261- if dify_config .REDIS_USE_SENTINEL :
262- redis_params = _get_base_redis_params ()
263- client = _create_sentinel_client (redis_params )
264- elif dify_config .REDIS_USE_CLUSTERS :
265- client = _create_cluster_client ()
266- else :
267- redis_params = _get_base_redis_params ()
268- client = _create_standalone_client (redis_params )
269-
270- # Initialize the wrapper and attach to app
271- redis_client .initialize (client )
272- app .extensions ["redis" ] = redis_client
273-
274-
275256def redis_fallback (default_return : Optional [Any ] = None ):
276257 """
277258 decorator to handle Redis operation exceptions and return a default value when Redis is unavailable.
0 commit comments