How do pipelining, MULTI/EXEC and Lua scripts differ in Redis?
Short answer
A pipeline only cuts network round trips and is not atomic. MULTI/EXEC runs a block of commands without interleaving but has no rollback. A Lua script runs atomically on the server and can branch on what it reads.
3 points to say:
- A pipeline sends many commands at once and is not atomic; MULTI/EXEC can't read results midway, and a failed command is not rolled back.
WATCHis an optimistic lock: under heavy contention it retries constantly, so Lua is usually better.- Lua handles "read, then decide to write"; keep scripts short because they block the whole instance; on Cluster all keys must share one slot.
Keep reading the deep dive
Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.