WAITAOF
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.
Options
Section titled “Options”| 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. |
Return value
Section titled “Return value”An array of two integers, in RESP2 and RESP3:
1if this server’s AOF on disk has the writes, else0(always0with the AOF off).- 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. |
Examples
Section titled “Examples”127.0.0.1:6379> SET invoice:77 "issued"OK127.0.0.1:6379> WAITAOF 1 1 10001) (integer) 12) (integer) 1Compatibility
Section titled “Compatibility”Same arguments, replies and errors as Redis 7.2 and later, and Valkey 8.
See also
Section titled “See also”WAIT, BGREWRITEAOF, persistence
In a cluster: Replicas and failover
Was this page helpful?
Thanks for the feedback.