What Is New in Predis 2
Predis 2 brings major internal refactoring and drops support for older PHP and Redis versions, focusing on modern development stacks.
| Category | Key Changes |
|---|---|
| New Features | Support for Redis 6, Redis Sentinel, and Redis Cluster. |
| Improvements | Complete internal refactoring, improved connection handling, and enhanced error management. |
| Backward Compatibility | Dropped support for PHP 5.x and Redis 1.0. Removed old connection parameters and command classes. |
| Bug Fixes | Resolved issues with cluster redistribution, pipeline execution, and socket timeouts. |
Why did Predis 2 drop support for older PHP versions?
Predis 2 requires PHP 7.2 or higher. This allows the codebase to use modern PHP features and type declarations, making the library more robust and maintainable.
Dropping legacy PHP versions simplifies the code and improves performance. In practice, this means you'll need to update your server environment if you're still running older PHP versions.
What Redis features does Predis 2.0.0 add?
Predis 2.0.0 adds official support for Redis 6, including its new commands and protocols. This includes Redis Sentinel for high availability and Redis Cluster for horizontal scaling.
The internal architecture was completely refactored to better handle these distributed setups. This matters because it provides more reliable connections to Redis clusters and sentinel configurations.
Is Predis 2 backward compatible with previous versions?
No, Predis 2 breaks backward compatibility in several significant ways. Support for Redis 1.0 was removed, and many old connection parameters and command classes were eliminated.
You'll need to update your configuration and code when migrating from v1. The internal refactoring changed how connections and commands are handled, so some custom implementations might need adjustments.
How does connection handling work in Predis 2?
Connection handling was completely rewritten for better reliability and performance. The new implementation provides more robust error handling and connection persistence.
This affects both standalone and clustered Redis deployments. You'll notice improved stability when dealing with network issues or failover scenarios in Redis Sentinel or Cluster setups.
FAQ
Can I upgrade from Predis v1 to v2 without code changes?
No, you'll need to update your code. The upgrade removes support for Redis 1.0 and changes how connections and commands are handled. Check your custom command implementations and connection parameters.
What is the minimum PHP version required for Predis 2?
Predis 2 requires PHP 7.2 or higher. The library uses modern PHP features that aren't available in older versions.
Does Predis 2 support Redis Cluster?
Yes, Predis 2 has improved support for Redis Cluster with better connection handling and error management for distributed setups.
Were any security vulnerabilities fixed in this release?
The changelog doesn't mention specific security fixes for v2.0.0. The focus was on architectural improvements and dropping support for outdated components.
How does Predis 2 handle Redis Sentinel compared to v1?
The Sentinel support was refactored for better reliability. The new implementation provides more robust failover detection and connection management in high-availability setups.