predis/predis
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
Predis/Predis is a flexible, feature-rich Redis client for PHP 7.2 and newer. It provides support for versions of Redis from 3.0 to 7.0, including support for clustering, master-slave replication setups, and Redis transactions. The client also includes an abstraction for Lua scripting and supports connections via TCP/IP or UNIX domain sockets.
To use Predis/Predis, you'll first need to install it using Composer:
composer require predis/predis
After installation, you can load the library and create a client instance. By default, Predis assumes 127.0.0.1
and 6379
as the host and port:
require 'Predis/Autoloader.php';
Predis\Autoloader::register();
$client = new Predis\Client();
$client->set('foo', 'bar');
$value = $client->get('foo');
For connecting to a different host and port, provide connection parameters in either URI format or a named array:
$client = new Predis\Client([
'scheme' => 'tcp',
'host' => '10.0.0.1',
'port' => 6379,
]);
Or:
$client = new Predis\Client('tcp://10.0.0.1:6379');
There are numerous features and usage scenarios based on your specific requirements, all of which are described comprehensively in the Predis documentation.
The Predis/Predis documentation can be found on the GitHub project page: https://github.com/predis/predis. It includes detailed usage examples along with frequently asked questions. For a step-by-step guide, refer to the Main features and How to install and use Predis sections.