Transactions in Redis
Redis as a NOSQL data store provides a loose sense of transaction. As in a traditional RDBMS, the transaction starts with a BEGIN
and ends with either COMMIT
or ROLLBACK
. All these RDBMS servers are multithreaded, so when a thread locks a resource, it cannot be manipulated by another thread unless and until the lock is released. Redis by default has MULTI
to start and EXEC
to execute the commands. In case of a transaction, the first command is always MULTI
, and after that all the commands are stored, and when EXEC
command is received, all the stored commands are executed in sequence. So inside the hood, once Redis receives the EXEC
command, all the commands are executed as a single isolated operation. Following are the
Get Learning Redis now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.