PHP
This section shows how to use a client called Predis, which is the PHP Redis client recommended by the community—although there are more than 10 open source Redis clients for PHP. The PHP version used to run all examples is 5.4.
Predis can be installed in many ways, and we have decided to use PHP Composer.
Create a file called composer.json in the chapter 5 folder with the following content:
{ "name": "redis/chapter5", "require": { "predis/predis": "~1.0" } }
Then run Composer:
$ composer update
In this section, the PHP code has comments that represent the result of the previous expression. It is recommended to run all of the code from this section in an interactive PHP interpreter (PsySH is recommended: http://psysh.org/).
The basic commands in PHP
Predis is a full-feature client, and most of Redis's commands can be accessed through a very simple interface. Each executed command returns a value synchronously...