PING
PING [message]
- Available since:
- Redis Open Source 1.0.0
- Time complexity:
- O(1)
- ACL categories:
-
@fast,@connection, - Compatibility:
- Redis Software and Redis Cloud compatibility
This command returns the simple string PONG if no argument is provided, otherwise it returns a copy of the
provided message as a bulk string.
This command is useful for:
- Testing whether a connection is still alive.
- Verifying the server's ability to serve data - an error is returned when this isn't the case (for example, during load from persistence data or accessing a stale replica).
- Measuring latency.
If a RESP2 client is subscribed to a channel, pattern, or shard channel, PING returns a
two-element array instead. The first element is the bulk string pong (lowercase). The
second is a copy of message if you provide one, or an empty bulk string if you don't.
RESP3 clients get the standard reply whether or not they're subscribed.
Optional arguments
message
A message to return instead of PONG.
Examples
redis> PING PONG redis> PING "hello world" "hello world"
Redis Software and Redis Cloud compatibility
| Redis Software |
Redis Cloud |
Notes |
|---|---|---|
| ✅ Standard |
✅ Standard |
Return information
Any of the following:
- Simple string reply:
PONGwhen no argument is provided. - Bulk string reply: the provided argument.
- Array reply: "
pong" and either the provided argument or an empty bulk string, when the client is in subscribed mode.