All contributions

predis/predis

Predis

A flexible, feature-complete Redis and Valkey client for PHP that handles single servers, clusters and replication through Sentinel.

Language
PHP
GitHub stars
7,782
Merged changes
3

What we changed

On a read error the ConnectionErrorProof pipeline returns the exception for the failed command and every one after it, and spl_object_id() replaces spl_object_hash(). Sentinel replica discovery uses SENTINEL REPLICAS and falls back to SENTINEL SLAVES on older servers.

What this work shows

  • Redis pipelines and connection errors
  • Redis Sentinel and Redis 4 compatibility
  • PHPUnit tests with data providers and mocks
  • PHP 8.6 deprecations
What was broken

Too few responses after a lost connection

When a read in the ConnectionErrorProof pipeline failed on a single node, executeSingleNode() counted the missing responses from a queue the commands had already been taken off. It then returned too short a list or threw a ValueError from array_fill().

How we fixed it

An exception for every unfinished command

The missing responses are now counted from the pipeline size, so the failed command and all later ones get the connection exception, as in executeCluster(). A data provider test covers a failure on the first, a middle and the last command.

#1739

What was broken

A deprecation warning on PHP 8.6

PHP 8.6 deprecates spl_object_hash(), and ConnectionErrorProof used it as the array key for per-connection exceptions in a cluster. The pipeline also had no test file of its own.

How we fixed it

spl_object_id() and pipeline tests

The key now comes from spl_object_id(), which works the same way without the warning. We added ConnectionErrorProofTest with cases for a write failure on a single connection and one failing node in a cluster.

#1738

What was broken

Replicas looked up with a legacy command

Predis looked up replicas with SENTINEL SLAVES, although Sentinel has offered SENTINEL REPLICAS since Redis 5.0. Older servers only know the old name, so simply swapping the command would break them.

How we fixed it

SENTINEL REPLICAS with a fallback to SLAVES

querySentinelForSlaves() sends SENTINEL REPLICAS, and when the Sentinel replies that it does not know the subcommand, it retries with SENTINEL SLAVES. We added a connected test and ran it against Sentinels from Redis 4.0 and 7.4.

#1745

Merged changes 3

  1. #1745 Use SENTINEL REPLICAS for Sentinel replica discovery Merged 12 October 2026
  2. #1739 Fix ConnectionErrorProof response count on single node read errors Merged 8 October 2026
  3. #1738 Replace deprecated spl_object_hash() with spl_object_id() in ConnectionErrorProof Merged 8 October 2026

What it taught us

The number of missing responses has to come from the commands that were sent, not from a queue part of which is already gone. When we switch a protocol command, we keep a path for older servers and check it against a real Sentinel, not only a mock.

More about this technology: PHP

Other projects we write code for

Describe your project.

A free quote comes back within an hour during working hours.