Skip to content

Commit afc83e1

Browse files
Add AsyncFunctionCommands (#2009)
1 parent 1256fdd commit afc83e1

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

redis/commands/core.py

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5485,6 +5485,9 @@ def readonly(self, **kwargs) -> ResponseT:
54855485
return self.execute_command("READONLY", **kwargs)
54865486

54875487

5488+
AsyncClusterCommands = ClusterCommands
5489+
5490+
54885491
class FunctionCommands:
54895492
"""
54905493
Redis Function commands
@@ -5497,7 +5500,7 @@ def function_load(
54975500
code: str,
54985501
replace: Optional[bool] = False,
54995502
description: Optional[str] = None,
5500-
) -> str:
5503+
) -> Union[Awaitable[str], str]:
55015504
"""
55025505
Load a library to Redis.
55035506
:param engine: the name of the execution engine for the library
@@ -5517,15 +5520,15 @@ def function_load(
55175520
pieces.append(code)
55185521
return self.execute_command("FUNCTION LOAD", *pieces)
55195522

5520-
def function_delete(self, library: str) -> str:
5523+
def function_delete(self, library: str) -> Union[Awaitable[str], str]:
55215524
"""
55225525
Delete the library called ``library`` and all its functions.
55235526
55245527
For more information check https://redis.io/commands/function-delete
55255528
"""
55265529
return self.execute_command("FUNCTION DELETE", library)
55275530

5528-
def function_flush(self, mode: str = "SYNC") -> str:
5531+
def function_flush(self, mode: str = "SYNC") -> Union[Awaitable[str], str]:
55295532
"""
55305533
Deletes all the libraries.
55315534
@@ -5535,7 +5538,7 @@ def function_flush(self, mode: str = "SYNC") -> str:
55355538

55365539
def function_list(
55375540
self, library: Optional[str] = "*", withcode: Optional[bool] = False
5538-
) -> List:
5541+
) -> Union[Awaitable[list], list]:
55395542
"""
55405543
Return information about the functions and libraries.
55415544
:param library: pecify a pattern for matching library names
@@ -5549,18 +5552,22 @@ def function_list(
55495552

55505553
def _fcall(
55515554
self, command: str, function, numkeys: int, *keys_and_args: Optional[List]
5552-
) -> str:
5555+
) -> Union[Awaitable[str], str]:
55535556
return self.execute_command(command, function, numkeys, *keys_and_args)
55545557

5555-
def fcall(self, function, numkeys: int, *keys_and_args: Optional[List]) -> str:
5558+
def fcall(
5559+
self, function, numkeys: int, *keys_and_args: Optional[List]
5560+
) -> Union[Awaitable[str], str]:
55565561
"""
55575562
Invoke a function.
55585563
55595564
For more information check https://redis.io/commands/fcall
55605565
"""
55615566
return self._fcall("FCALL", function, numkeys, *keys_and_args)
55625567

5563-
def fcall_ro(self, function, numkeys: int, *keys_and_args: Optional[List]) -> str:
5568+
def fcall_ro(
5569+
self, function, numkeys: int, *keys_and_args: Optional[List]
5570+
) -> Union[Awaitable[str], str]:
55645571
"""
55655572
This is a read-only variant of the FCALL command that cannot
55665573
execute commands that modify data.
@@ -5569,7 +5576,7 @@ def fcall_ro(self, function, numkeys: int, *keys_and_args: Optional[List]) -> st
55695576
"""
55705577
return self._fcall("FCALL_RO", function, numkeys, *keys_and_args)
55715578

5572-
def function_dump(self) -> str:
5579+
def function_dump(self) -> Union[Awaitable[str], str]:
55735580
"""
55745581
Return the serialized payload of loaded libraries.
55755582
@@ -5582,7 +5589,9 @@ def function_dump(self) -> str:
55825589

55835590
return self.execute_command("FUNCTION DUMP", **options)
55845591

5585-
def function_restore(self, payload: str, policy: Optional[str] = "APPEND") -> str:
5592+
def function_restore(
5593+
self, payload: str, policy: Optional[str] = "APPEND"
5594+
) -> Union[Awaitable[str], str]:
55865595
"""
55875596
Restore libraries from the serialized ``payload``.
55885597
You can use the optional policy argument to provide a policy
@@ -5592,15 +5601,15 @@ def function_restore(self, payload: str, policy: Optional[str] = "APPEND") -> st
55925601
"""
55935602
return self.execute_command("FUNCTION RESTORE", payload, policy)
55945603

5595-
def function_kill(self) -> str:
5604+
def function_kill(self) -> Union[Awaitable[str], str]:
55965605
"""
55975606
Kill a function that is currently executing.
55985607
55995608
For more information check https://redis.io/commands/function-kill
56005609
"""
56015610
return self.execute_command("FUNCTION KILL")
56025611

5603-
def function_stats(self) -> list:
5612+
def function_stats(self) -> Union[Awaitable[list], list]:
56045613
"""
56055614
Return information about the function that's currently running
56065615
and information about the available execution engines.
@@ -5610,7 +5619,7 @@ def function_stats(self) -> list:
56105619
return self.execute_command("FUNCTION STATS")
56115620

56125621

5613-
AsyncClusterCommands = ClusterCommands
5622+
AsyncFunctionCommands = FunctionCommands
56145623

56155624

56165625
class DataAccessCommands(
@@ -5671,6 +5680,7 @@ class AsyncCoreCommands(
56715680
AsyncModuleCommands,
56725681
AsyncPubSubCommands,
56735682
AsyncScriptCommands,
5683+
AsyncFunctionCommands,
56745684
):
56755685
"""
56765686
A class containing all of the implemented redis commands. This class is

0 commit comments

Comments
 (0)