EBOOK – REDIS IN ACTION

This book covers the use of Redis, an in-memory database/data structure server.

open all | close all

11.3 Doing away with WATCH/MULTI/EXEC

In previous chapters, we used a combination of WATCH, MULTI, and EXEC in several
cases to implement a form of transaction in Redis. Generally, when there are few writers
modifying WATCHed data, these transactions complete without significant contention
or retries. But if operations can take several round trips to execute, if contention
is high, or if network latency is high, clients may need to perform many retries in
order to complete operations.

In this section, we’ll revisit our autocomplete example from chapter 6 along with
our marketplace example originally covered in chapter 4 to show how we can simplify
our code and improve performance at the same time.

First up, let’s look at one of our autocomplete examples from chapter 6.