Upstash Documentation

WAIT

Wait for replica acknowledgements.
2 min read

Use WAIT to block until preceding writes have been acknowledged by a number of replicas, or until a timeout expires.

The reply is the number of replicas that acknowledged, which can be lower than <numreplicas> when the timeout is reached, so callers must check it instead of assuming success. A timeout of 0 waits indefinitely.

WAIT raises the durability you can observe for a write, which is useful right before an action that must not be undone by a failover, such as replying to a payment webhook. It does not make Redis strongly consistent: an acknowledged write can still be lost if the primary and the acknowledging replicas fail together.

On Upstash the command waits for the writes enqueued before it began, including writes made by other connections, which is broader than the per-connection wording used by some Redis clients.

Syntax#

Arguments#

ArgumentRequiredRepeatableDescription
numreplicasYesNoNon-negative number of replicas that should acknowledge prior writes on this connection.
timeoutYesNoMaximum wait in milliseconds; 0 means no timeout.

Important points#

  • This deployment waits for writes enqueued before WAIT begins, including writes from other connections. That is broader than the per-connection wording used by Redis clients.
  • The reply can be lower than numreplicas when the timeout expires. This improves observed replication durability but does not make Redis a strongly consistent store.

Response#

The reply reports the result of the operation. Error replies have the same shape in RESP2 and RESP3 and are surfaced as exceptions by the SDKs below.

ProtocolReply
RESP2Integer
RESP3Integer
Note

Client libraries often decode bulk strings, maps, sets, and numeric strings into language-native values. The table describes the Redis wire reply.

Examples#

TCP examples use the TLS REDIS_URL from the Upstash console. REST examples use UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN.

Redis CLI
@upstash/redis
Note

This command is not supported yet in @upstash/redis.

upstash_redis
Note

This command is not supported yet in upstash_redis.

ioredis
node-redis
redis-py
go-redis
jedis
redis-rs