Skip to content

Ask the HotKV docs

Answers come only from these docs and can be wrong; check the linked pages before you rely on them.

WAITAOF

Last updated
WAITAOF numlocal numreplicas timeout
Group
Server
Complexity
O(1)
Arity
4 (exactly, counting the command name)
Flags
blocking
HotKV Cloud
All plans
On-Premise
no license needed

WAITAOF waits until every write this connection made so far is in an append-only file (AOF) on disk: on this server when numlocal is 1, and on at least numreplicas replicas. It returns as soon as both are true, or when timeout milliseconds pass, and reports how far it got either way.

When the AOF reaches the disk depends on appendfsync: at once with always, within about a second with everysec, and only at the next rewrite with no. Each replica follows its own appendfsync. With everysec, a short timeout can run out before the fsync, so give it a second or more.

The connection is blocked while it waits; other clients are served as usual. Inside MULTI or a script, WAITAOF replies at once with the current state.

Argument Meaning
numlocal 1 to wait for this server’s AOF, 0 not to. Needs appendonly yes when 1.
numreplicas How many replicas must have the writes in their AOF on disk.
timeout Milliseconds to wait at most. 0 waits as long as it takes.

An array of two integers, in RESP2 and RESP3:

  1. 1 if this server’s AOF on disk has the writes, else 0 (always 0 with the AOF off).
  2. The number of replicas whose AOF on disk has them.
Error case Error
numlocal not an integer ERR value is not an integer or out of range
numlocal not 0 or 1 ERR value is out of range, value must between 0 and 1
numreplicas not a non-negative integer ERR value is out of range, must be positive
timeout not an integer ERR timeout is not an integer or out of range
timeout negative ERR timeout is negative
Sent to a replica ERR WAITAOF cannot be used with replica instances. Please also note that writes to replicas are just local and are not propagated.
numlocal 1 with the AOF off ERR WAITAOF cannot be used when numlocal is set but appendonly is disabled.
127.0.0.1:6379> SET invoice:77 "issued"
OK
127.0.0.1:6379> WAITAOF 1 1 1000
1) (integer) 1
2) (integer) 1

Same arguments, replies and errors as Redis 7.2 and later, and Valkey 8.

WAIT, BGREWRITEAOF, persistence

In a cluster: Replicas and failover