phpredis/phpredis
FreeA PHP extension for Redis
FreeFree tier
About phpredis/phpredis
phpredis is a PHP extension that provides an API for communicating with the Redis key-value store. It supports Redis Cluster, Sentinel, and various Redis features such as arrays, sessions, and pub/sub. The extension is written in C and is designed for high performance. It also includes support for compatible stores like KeyDB and Valkey. The project is actively maintained on GitHub with over 10,000 stars and frequent releases.
Key Features
Full Redis command support (strings, hashes, lists, sets, sorted sets, hyperloglogs, geospatial, streams)
Redis Cluster support for automatic sharding and failover
Redis Sentinel support for high availability
Redis Array (client-side sharding) support
Session handler for storing PHP sessions in Redis
Supports serialization of PHP data types
Optimized for performance, written in C
Active development with regular releases
Pros & Cons
Pros
- Free and open source (PHP License)
- Comprehensive Redis feature support including clustering and sentinel
- High performance due to C implementation
- Widely adopted with strong community and GitHub stars (10k+)
- Regular updates and compatibility with latest Redis versions
- Supports alternative stores like KeyDB and Valkey
Cons
- Requires compilation as a PHP extension (not a pure PHP library)
- Only works with PHP, not other languages
- May require additional configuration for complex Redis setups
- Some advanced Redis features (e.g., Redis Stack modules) may need separate handling
Best For
High-performance caching layer for PHP applicationsSession storage and managementReal-time data processing and messaging (pub/sub)Rate limiting and countersLeaderboards and real-time analyticsMessage queues and job management
FAQ
How do I install phpredis?
phpredis can be installed by compiling from source (using phpize and make) or via PECL (pecl install redis). Detailed installation instructions are available in the INSTALL.md file in the GitHub repository.
Does phpredis support Redis Cluster?
Yes, phpredis supports Redis Cluster, allowing you to connect to a cluster of Redis nodes with automatic data sharding and failover. See the cluster.md documentation in the repository.
What PHP versions does phpredis support?
The extension supports PHP 7.0 and later, including PHP 8.x. The latest releases are tested against PHP 8.1, 8.2, 8.3, and 8.4.
Is phpredis compatible with Redis Sentinel?
Yes, phpredis includes full support for Redis Sentinel, enabling high availability and automatic failover. Refer to the sentinel.md documentation for usage details.