@@ -284,6 +284,7 @@ class RedisCluster(RedisClusterCommands):
284284 "READONLY" ,
285285 "READWRITE" ,
286286 "TIME" ,
287+ "GRAPH.CONFIG" ,
287288 ],
288289 DEFAULT_NODE ,
289290 ),
@@ -810,6 +811,10 @@ def lock(
810811 thread_local = thread_local ,
811812 )
812813
814+ def set_response_callback (self , command , callback ):
815+ """Set a custom Response Callback"""
816+ self .cluster_response_callbacks [command ] = callback
817+
813818 def _determine_nodes (self , * args , ** kwargs ):
814819 command = args [0 ]
815820 nodes_flag = kwargs .pop ("nodes_flag" , None )
@@ -1181,6 +1186,20 @@ def _process_result(self, command, res, **kwargs):
11811186 else :
11821187 return res
11831188
1189+ def load_external_module (
1190+ self ,
1191+ funcname ,
1192+ func ,
1193+ ):
1194+ """
1195+ This function can be used to add externally defined redis modules,
1196+ and their namespaces to the redis client.
1197+
1198+ ``funcname`` - A string containing the name of the function to create
1199+ ``func`` - The function, being added to this class.
1200+ """
1201+ setattr (self , funcname , func )
1202+
11841203
11851204class ClusterNode :
11861205 def __init__ (self , host , port , server_type = None , redis_connection = None ):
@@ -2026,7 +2045,13 @@ def _send_cluster_commands(
20262045
20272046 # turn the response back into a simple flat array that corresponds
20282047 # to the sequence of commands issued in the stack in pipeline.execute()
2029- response = [c .result for c in sorted (stack , key = lambda x : x .position )]
2048+ response = []
2049+ for c in sorted (stack , key = lambda x : x .position ):
2050+ if c .args [0 ] in self .cluster_response_callbacks :
2051+ c .result = self .cluster_response_callbacks [c .args [0 ]](
2052+ c .result , ** c .options
2053+ )
2054+ response .append (c .result )
20302055
20312056 if raise_on_error :
20322057 self .raise_first_error (stack )
@@ -2040,6 +2065,9 @@ def _fail_on_redirect(self, allow_redirections):
20402065 "ASK & MOVED redirection not allowed in this pipeline"
20412066 )
20422067
2068+ def exists (self , * keys ):
2069+ return self .execute_command ("EXISTS" , * keys )
2070+
20432071 def eval (self ):
20442072 """ """
20452073 raise RedisClusterException ("method eval() is not implemented" )
0 commit comments