Redis transactions
Redis "transactions" with MULTI / EXEC are different from DB transactions — they queue commands and run the whole batch atomically, uninterrupted by other clients, but there's no rollback if one command fails. The useful pattern is optimistic locking with WATCH: watch a key, read it, compute the update, MULTI / EXEC; if anyone else modified the watched key in between, the EXEC returns nil and you retry. Classic uses: atomic balance decrements (don't overdraw), unique reservations (first to book wins). For simple atomicity — "increment this counter, push to this list, all-or-nothing" — MULTI / EXEC is enough; for "read, decide, write atomically" you need WATCH or a Lua script (cleaner and avoids the round-trip retry). Don't confuse MULTI with a pipeline — pipelines just batch commands over the network for throughput, without atomicity.