Atomicity in Redis: MULTI/EXEC, WATCH, Lua Scripts and Redis Functions
In Redis, MULTI/EXEC runs commands in order with nobody in between, but it does not roll back; for multi-step work that decides based on a read, the right tool is usually a Lua script. With real output: a stock of 100 copies sold 200 times, 14,620 retries with WATCH, StackExchange.Redis conditions, stock reservation with LuaScript.Prepare, the script cache, Redis Functions surviving a restart, Redis 8.8's INCREX and a long script that locks the server.
14 Nov 2026
·
15 min
·
11