/plushcap/analysis/redis/redis-you-dont-need-transaction-rollbacks-in-redis

You Don’t Need Transaction Rollbacks in Redis

What's this blog post about?

Redis features two main mechanisms for executing multiple operations atomically: MULTI/EXEC transactions and Lua scripts. Transactions in Redis start with the MULTI command and are "one shot" - a sequence of commands that get executed all at once. WATCH is used to perform optimistic locking, ensuring that subsequent transactions will be executed only if the keys being watched have not changed before EXEC gets called. Lua scripts can read data from Redis without needing optimistic locking and are more efficient than "Watched" transactions because they don't require optimistic locking to read values. While WATCH can be very useful for performing articulated transactions, it’s usually easier and more efficient to use a Lua script when you need to perform multiple operations that depend on data in Redis.

Company
Redis

Date published
May 4, 2020

Author(s)
Redis

Word count
1954

Hacker News points
None found.

Language
English


By Matt Makai. 2021-2024.