Redis: A technique for Verifying Propagation of Writes
Interesting idea on how to emulate in Redis MongoDB’s db.runCommand( { getlasterror : 1 , w : 2 } )[1] to verify propagation of writes:
Have client establish two connections - one to master Redis and one to slave Redis.
Now when client wants to write KEY to both master and slave:
- Client
SUBSCRIBEs to KEY on slave- Client writes KEY (e.g. set foo bar) to master
- Client publishes KEY to master
Assuming redis-master will serialize the updates:
- Master will replicate KEY to slave
- Master will propagate PUBLISH KEY to slave
Finally client:
- Gets KEY event on SUBSCRIBE!
You can probably replace Pub and Subs with
RPUSHandBLPOPrespectively.
Couple of comments:
- using PUB/SUB will require an async client that will need to perform coordination to conclude the propagation was successful
- using
RPUSHandBLPOPwould allow a sync client, that can also set up timeouts
Original title and link: Redis: A technique for Verifying Propagation of Writes (NoSQL databases © myNoSQL)