DEV Community

techdurjoy
techdurjoy

Posted on • Updated on

A Complete Beginners Guide of Predis Package

Predis does not require any additional C extension by default, but it can be optionally paired with phpiredis to lower the overhead of the serialization and parsing of the Redis RESP Protocol.

More details about this project can be found on the frequently asked questions.

Main features

Support for Redis from 2.0 to 6.0.
Support for clustering using client-side sharding and pluggable keyspace distributors.
Support for redis-cluster (Redis >= 3.0).
Support for master-slave replication setups and redis-sentinel.
Transparent key prefixing of keys using a customizable prefix strategy.
Command pipelining on both single nodes and clusters (client-side sharding only).
Abstraction for Redis transactions (Redis >= 2.0) and CAS operations (Redis >= 2.2).
Abstraction for Lua scripting (Redis >= 2.6) and automatic switching between EVALSHA or EVAL.
Abstraction for SCAN, SSCAN, ZSCAN and HSCAN (Redis >= 2.8) based on PHP iterators.
Connections are established lazily by the client upon the first command and can be persisted.
Connections can be established via TCP/IP (also TLS/SSL-encrypted) or UNIX domain sockets.
Support for Webdis (requires both ext-curl and ext-phpiredis).
Support for custom connection classes for providing different network or protocol backends.
Flexible system for defining custom commands and override the default ones.
Enter fullscreen mode Exit fullscreen mode




How to install and use Predis

This library can be found on Packagist for an easier management of projects dependencies using Composer. Compressed archives of each release are available on GitHub.

Loading the library

Predis relies on the autoloading features of PHP to load its files when needed and complies with the PSR-4 standard. Autoloading is handled automatically when dependencies are managed through Composer, but it is also possible to leverage its own autoloader in projects or scripts lacking any autoload facility:
A Complete Beginners Guide of Predis Package
Laravel 8.x Cursor Based Pagination Example

Top comments (0)