Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions redis/asyncio/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1161,9 +1161,12 @@ async def get_message(
return await self.handle_message(response, ignore_subscribe_messages)
return None

def ping(self, message=None) -> Awaitable:
def ping(self, message=None) -> Awaitable[bool]:
"""
Ping the Redis server
Ping the Redis server to test connectivity.
Sends a PING command to the Redis server and returns True if the server
responds with "PONG".
"""
args = ["PING", message] if message is not None else ["PING"]
return self.execute_command(*args)
Expand Down
5 changes: 4 additions & 1 deletion redis/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1186,7 +1186,10 @@ def get_message(

def ping(self, message: Union[str, None] = None) -> bool:
"""
Ping the Redis server
Ping the Redis server to test connectivity.
Sends a PING command to the Redis server and returns True if the server
responds with "PONG".
"""
args = ["PING", message] if message is not None else ["PING"]
return self.execute_command(*args)
Expand Down
13 changes: 10 additions & 3 deletions redis/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1210,11 +1210,18 @@ def latency_reset(self, *events: str) -> ResponseT:
"""
return self.execute_command("LATENCY RESET", *events)

def ping(self, **kwargs) -> ResponseT:
def ping(self, **kwargs) -> Union[Awaitable[bool], bool]:
"""
Ping the Redis server
Ping the Redis server to test connectivity.

For more information, see https://redis.io/commands/ping
Sends a PING command to the Redis server and returns True if the server
responds with "PONG".

This command is useful for:
- Testing whether a connection is still alive
- Verifying the server's ability to serve data

For more information on the underlying ping command see https://redis.io/commands/ping
"""
return self.execute_command("PING", **kwargs)

Expand Down