diff --git a/python/python/pybushka/async_commands/cmd_commands.py b/python/python/pybushka/async_commands/cmd_commands.py index fe62add4da..d84410d693 100644 --- a/python/python/pybushka/async_commands/cmd_commands.py +++ b/python/python/pybushka/async_commands/cmd_commands.py @@ -31,7 +31,7 @@ async def custom_command(self, command_args: List[str]) -> TResult: connection.customCommand(["CLIENT", "LIST","TYPE", "PUBSUB"]) Args: - command_args (List[str]): List of strings of the command's arguements. + command_args (List[str]): List of strings of the command's arguments. Every part of the command, including the command name and subcommands, should be added as a separate value in args. Returns: @@ -86,3 +86,11 @@ async def select(self, index: int) -> OK: A simple OK response. """ return await self._execute_command(RequestType.Select, [str(index)]) + + async def config_reset_stat(self) -> OK: + """Reset the statistics reported by Redis. + See https://redis.io/commands/config-resetstat/ for details. + Returns: + OK: Returns "OK" to confirm that the statistics were successfully reset. + """ + return await self._execute_command(RequestType.ConfigResetStat, []) diff --git a/python/python/pybushka/async_commands/cme_commands.py b/python/python/pybushka/async_commands/cme_commands.py index 69396db393..04ad7aedad 100644 --- a/python/python/pybushka/async_commands/cme_commands.py +++ b/python/python/pybushka/async_commands/cme_commands.py @@ -1,7 +1,7 @@ from typing import List, Optional, Union from pybushka.async_commands.core import BaseTransaction, CoreCommands, InfoSection -from pybushka.constants import TResult +from pybushka.constants import OK, TResult from pybushka.protobuf.redis_request_pb2 import RequestType from pybushka.routes import TRoute @@ -24,9 +24,9 @@ async def custom_command( connection.customCommand(["CLIENT", "LIST","TYPE", "PUBSUB"], AllNodes()) Args: - command_args (List[str]): List of strings of the command's arguements. + command_args (List[str]): List of strings of the command's arguments. Every part of the command, including the command name and subcommands, should be added as a separate value in args. - route (Optional[TRoute], optional): The command will be routed automatically, unless `route` is provided, in which + route (Optional[TRoute]): The command will be routed automatically, unless `route` is provided, in which case the client will initially try to route the command to the nodes defined by `route`. Defaults to None. Returns: @@ -47,7 +47,7 @@ async def info( Args: sections (Optional[List[InfoSection]]): A list of InfoSection values specifying which sections of information to retrieve. When no parameter is provided, the default option is assumed. - route (Optional[TRoute], optional): The command will be routed automatically, unless `route` is provided, in which + route (Optional[TRoute]): The command will be routed automatically, unless `route` is provided, in which case the client will initially try to route the command to the nodes defined by `route`. Defaults to None. Returns: @@ -68,7 +68,7 @@ async def exec( Args: transaction (ClusterTransaction): A ClusterTransaction object containing a list of commands to be executed. - route (Optional[TRoute], optional): The command will be routed automatically, unless `route` is provided, in which + route (Optional[TRoute]): The command will be routed automatically, unless `route` is provided, in which case the client will initially try to route the command to the nodes defined by `route`. Defaults to None. Returns: @@ -78,3 +78,17 @@ async def exec( """ commands = transaction.commands[:] return await self.execute_transaction(commands, route) + + async def config_reset_stat( + self, + route: Optional[TRoute] = None, + ) -> OK: + """Reset the statistics reported by Redis. + See https://redis.io/commands/config-resetstat/ for details. + Args: + route (Optional[TRoute]): The command will be routed automatically, unless `route` is provided, in which + case the client will initially try to route the command to the nodes defined by `route`. Defaults to None. + Returns: + OK: Returns "OK" to confirm that the statistics were successfully reset. + """ + return await self._execute_command(RequestType.ConfigResetStat, [], route) diff --git a/python/python/pybushka/async_commands/core.py b/python/python/pybushka/async_commands/core.py index 4478d093a7..e1c7915de0 100644 --- a/python/python/pybushka/async_commands/core.py +++ b/python/python/pybushka/async_commands/core.py @@ -193,7 +193,7 @@ def custom_command(self, command_args: List[str]): connection.customCommand(["CLIENT", "LIST","TYPE", "PUBSUB"]) Args: - command_args (List[str]): List of strings of the command's arguements. + command_args (List[str]): List of strings of the command's arguments. Every part of the command, including the command name and subcommands, should be added as a separate value in args. Command response: @@ -228,6 +228,14 @@ def delete(self, keys: List[str]): """ self.append_command(RequestType.Del, keys) + def config_reset_stat(self): + """Reset the statistics reported by Redis. + See https://redis.io/commands/config-resetstat/ for details. + Command response: + OK: Returns "OK" to confirm that the statistics were successfully reset. + """ + self.append_command(RequestType.ConfigResetStat, []) + class CoreCommands: async def set( diff --git a/python/python/tests/test_async_client.py b/python/python/tests/test_async_client.py index a1ea100edf..45fbc08302 100644 --- a/python/python/tests/test_async_client.py +++ b/python/python/tests/test_async_client.py @@ -233,6 +233,21 @@ async def test_delete(self, redis_client: BaseRedisClient): assert await redis_client.delete(delete_keys) == 3 assert await redis_client.delete(keys) == 0 + @pytest.mark.parametrize("cluster_mode", [True, False]) + async def test_config_reset_stat(self, redis_client: BaseRedisClient): + await redis_client.set("foo", "bar") + info_stats = parse_info_response( + get_first_result(await redis_client.info([InfoSection.STATS])) + ) + assert int(info_stats["total_commands_processed"]) > 1 + assert await redis_client.config_reset_stat() == OK + info_stats = parse_info_response( + get_first_result(await redis_client.info([InfoSection.STATS])) + ) + + # 1 stands for the second info command + assert info_stats["total_commands_processed"] == "1" + class CommandsUnitTests: def test_expiry_cmd_args(self):