Skip to Content
Mastering PHP 7
book

Mastering PHP 7

by Branko Ajzele
June 2017
Intermediate to advanced
536 pages
9h 49m
English
Packt Publishing
Content preview from Mastering PHP 7

Transactions

Much like MongoDB, Redis also does not have ACID support in a sense that MySQL has, which is alright really, as Redis is just a key/value store and not a relational database. Redis, however, provides a level of atomicity. Using MULTI, EXEC, DISCARD, and WATCH, we are able to execute a group of commands within a single step, during which Redis makes the following two guarantees:

  • Another client request can never be served in the middle of our group-commands execution
  • Either all or none of the commands are processed

Let's take a look at the following example:

<?phptry {    $client = new Redis();    $client->connect('localhost', 6379);    $client->multi();    $result1 = $client->set('tKey1', 'Test#1'); // Valid command    $result2 = $client ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning PHP 7

Learning PHP 7

Antonio L Zapata (GBP)
Upgrading to PHP 5

Upgrading to PHP 5

Adam Trachtenberg

Publisher Resources

ISBN: 9781785882814Supplemental Content