A transaction in a relational database is a group of operations performed as an atomic action within a it. This means the group of operations must either complete or fail as a whole. However, the concept of transactions in Redis is a different story. In this recipe, we'll take a look at Redis transactions, and find out the differences in transactions between Redis and RDBMS.
You need to finish the installation of the Redis Server as we described in the Downloading and installing Redis recipe in Chapter 1, Getting Started with Redis.
To understand Redis transactions, there is a scenario where we are going to organize a coupon codes seckilling, a quick sell out online, for a certain restaurant in Relp. There are only five coupon codes for this seckilling and we have a key, counts:seckilling
, as a counter to hold the count of available coupon codes.
Here is the pseudo-code for this counter implementation:
//Initiate the count of coupon...