Fabio
Fabio

Reputation: 3120

Redis replication order

In a master-slave scenario, Redis replication is made in an asynchronous way. But is it guaranteed that the commands are replicated in order? If I have these commands:

SET key1 111
SET key2 222
SET key3 333

If the slave node has "key2", then I can say for sure that it'll also have "key1"?

Upvotes: 1

Views: 190

Answers (1)

Kevin Christopher Henry
Kevin Christopher Henry

Reputation: 49112

Yes, commands are replicated in order. Anything else wouldn't actually be replication.

As described in the documentation, both the master and the replica keep track of an offset indicating where they are in the stream of commands. That allows the replica to know if it receives a command out of order and not process it prematurely.

Upvotes: 3

Related Questions