@@ -6105,6 +6105,131 @@ def function_stats(self) -> Union[Awaitable[List], List]:
6105
6105
AsyncFunctionCommands = FunctionCommands
6106
6106
6107
6107
6108
+ class GearsCommands :
6109
+ def tfunction_load (
6110
+ self , lib_code : str , replace : bool = False , config : Union [str , None ] = None
6111
+ ) -> ResponseT :
6112
+ """
6113
+ Load a new library to RedisGears.
6114
+
6115
+ ``lib_code`` - the library code.
6116
+ ``config`` - a string representation of a JSON object
6117
+ that will be provided to the library on load time,
6118
+ for more information refer to
6119
+ https://github.com/RedisGears/RedisGears/blob/master/docs/function_advance_topics.md#library-configuration
6120
+ ``replace`` - an optional argument, instructs RedisGears to replace the
6121
+ function if its already exists
6122
+
6123
+ For more information see https://redis.io/commands/tfunction-load/
6124
+ """
6125
+ pieces = []
6126
+ if replace :
6127
+ pieces .append ("REPLACE" )
6128
+ if config is not None :
6129
+ pieces .extend (["CONFIG" , config ])
6130
+ pieces .append (lib_code )
6131
+ return self .execute_command ("TFUNCTION LOAD" , * pieces )
6132
+
6133
+ def tfunction_delete (self , lib_name : str ) -> ResponseT :
6134
+ """
6135
+ Delete a library from RedisGears.
6136
+
6137
+ ``lib_name`` the library name to delete.
6138
+
6139
+ For more information see https://redis.io/commands/tfunction-delete/
6140
+ """
6141
+ return self .execute_command ("TFUNCTION DELETE" , lib_name )
6142
+
6143
+ def tfunction_list (
6144
+ self ,
6145
+ with_code : bool = False ,
6146
+ verbose : int = 0 ,
6147
+ lib_name : Union [str , None ] = None ,
6148
+ ) -> ResponseT :
6149
+ """
6150
+ List the functions with additional information about each function.
6151
+
6152
+ ``with_code`` Show libraries code.
6153
+ ``verbose`` output verbosity level, higher number will increase verbosity level
6154
+ ``lib_name`` specifying a library name (can be used multiple times to show multiple libraries in a single command) # noqa
6155
+
6156
+ For more information see https://redis.io/commands/tfunction-list/
6157
+ """
6158
+ pieces = []
6159
+ if with_code :
6160
+ pieces .append ("WITHCODE" )
6161
+ if verbose >= 1 and verbose <= 3 :
6162
+ pieces .append ("v" * verbose )
6163
+ else :
6164
+ raise DataError ("verbose can be 1, 2 or 3" )
6165
+ if lib_name is not None :
6166
+ pieces .append ("LIBRARY" )
6167
+ pieces .append (lib_name )
6168
+
6169
+ return self .execute_command ("TFUNCTION LIST" , * pieces )
6170
+
6171
+ def _tfcall (
6172
+ self ,
6173
+ lib_name : str ,
6174
+ func_name : str ,
6175
+ keys : KeysT = None ,
6176
+ _async : bool = False ,
6177
+ * args : List ,
6178
+ ) -> ResponseT :
6179
+ pieces = [f"{ lib_name } .{ func_name } " ]
6180
+ if keys is not None :
6181
+ pieces .append (len (keys ))
6182
+ pieces .extend (keys )
6183
+ else :
6184
+ pieces .append (0 )
6185
+ if args is not None :
6186
+ pieces .extend (args )
6187
+ if _async :
6188
+ return self .execute_command ("TFCALLASYNC" , * pieces )
6189
+ return self .execute_command ("TFCALL" , * pieces )
6190
+
6191
+ def tfcall (
6192
+ self ,
6193
+ lib_name : str ,
6194
+ func_name : str ,
6195
+ keys : KeysT = None ,
6196
+ * args : List ,
6197
+ ) -> ResponseT :
6198
+ """
6199
+ Invoke a function.
6200
+
6201
+ ``lib_name`` - the library name contains the function.
6202
+ ``func_name`` - the function name to run.
6203
+ ``keys`` - the keys that will be touched by the function.
6204
+ ``args`` - Additional argument to pass to the function.
6205
+
6206
+ For more information see https://redis.io/commands/tfcall/
6207
+ """
6208
+ return self ._tfcall (lib_name , func_name , keys , False , * args )
6209
+
6210
+ def tfcall_async (
6211
+ self ,
6212
+ lib_name : str ,
6213
+ func_name : str ,
6214
+ keys : KeysT = None ,
6215
+ * args : List ,
6216
+ ) -> ResponseT :
6217
+ """
6218
+ Invoke an async function (coroutine).
6219
+
6220
+ ``lib_name`` - the library name contains the function.
6221
+ ``func_name`` - the function name to run.
6222
+ ``keys`` - the keys that will be touched by the function.
6223
+ ``args`` - Additional argument to pass to the function.
6224
+
6225
+ For more information see https://redis.io/commands/tfcall/
6226
+ """
6227
+ return self ._tfcall (lib_name , func_name , keys , True , * args )
6228
+
6229
+
6230
+ AsyncGearsCommands = GearsCommands
6231
+
6232
+
6108
6233
class DataAccessCommands (
6109
6234
BasicKeyCommands ,
6110
6235
HyperlogCommands ,
@@ -6148,6 +6273,7 @@ class CoreCommands(
6148
6273
PubSubCommands ,
6149
6274
ScriptCommands ,
6150
6275
FunctionCommands ,
6276
+ GearsCommands ,
6151
6277
):
6152
6278
"""
6153
6279
A class containing all of the implemented redis commands. This class is
@@ -6164,6 +6290,7 @@ class AsyncCoreCommands(
6164
6290
AsyncPubSubCommands ,
6165
6291
AsyncScriptCommands ,
6166
6292
AsyncFunctionCommands ,
6293
+ AsyncGearsCommands ,
6167
6294
):
6168
6295
"""
6169
6296
A class containing all of the implemented redis commands. This class is
0 commit comments