Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Redis Essentials

You're reading from   Redis Essentials Harness the power of Redis to integrate and manage your projects efficiently

Arrow left icon
Product type Paperback
Published in Sep 2015
Publisher Packt
ISBN-13 9781784392451
Length 230 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Toc

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. Some basic commands are shown in the following lines, and after...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image