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
Important points
- This deployment waits for writes enqueued before
WAITbegins, including writes from other connections. That is broader than the per-connection wording used by Redis clients. - The reply can be lower than
numreplicaswhen 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.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 TLSREDIS_URL from the Upstash console. REST examples use UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN.
Redis CLI
Redis CLI
@upstash/redis
@upstash/redis
This command is not supported yet in
@upstash/redis.upstash_redis
upstash_redis
This command is not supported yet in
upstash_redis.ioredis
ioredis
node-redis
node-redis
redis-py
redis-py
go-redis
go-redis
jedis
jedis
redis-rs
redis-rs