@@ -284,6 +284,7 @@ class RedisCluster(RedisClusterCommands):
284
284
"READONLY" ,
285
285
"READWRITE" ,
286
286
"TIME" ,
287
+ "GRAPH.CONFIG" ,
287
288
],
288
289
DEFAULT_NODE ,
289
290
),
@@ -810,6 +811,10 @@ def lock(
810
811
thread_local = thread_local ,
811
812
)
812
813
814
+ def set_response_callback (self , command , callback ):
815
+ """Set a custom Response Callback"""
816
+ self .cluster_response_callbacks [command ] = callback
817
+
813
818
def _determine_nodes (self , * args , ** kwargs ):
814
819
command = args [0 ]
815
820
nodes_flag = kwargs .pop ("nodes_flag" , None )
@@ -1181,6 +1186,20 @@ def _process_result(self, command, res, **kwargs):
1181
1186
else :
1182
1187
return res
1183
1188
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
+
1184
1203
1185
1204
class ClusterNode :
1186
1205
def __init__ (self , host , port , server_type = None , redis_connection = None ):
@@ -2026,7 +2045,13 @@ def _send_cluster_commands(
2026
2045
2027
2046
# turn the response back into a simple flat array that corresponds
2028
2047
# 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 )
2030
2055
2031
2056
if raise_on_error :
2032
2057
self .raise_first_error (stack )
@@ -2040,6 +2065,9 @@ def _fail_on_redirect(self, allow_redirections):
2040
2065
"ASK & MOVED redirection not allowed in this pipeline"
2041
2066
)
2042
2067
2068
+ def exists (self , * keys ):
2069
+ return self .execute_command ("EXISTS" , * keys )
2070
+
2043
2071
def eval (self ):
2044
2072
""" """
2045
2073
raise RedisClusterException ("method eval() is not implemented" )
0 commit comments