Here is a new patch release for v1.1
with more improvements and fixes.
NOTE: We are still missing handlers for commands added in Redis 4, 5 and 6. We will get on par eventually, in the meanwhile you can define your own ones or use Predis\Client::executeRaw()
. Read this post for details about how to properly implement support for new commands if you would like to add missing ones and share your work with us by creating pull requests, contributions are always greatly appreciated!
-
The client can now handle ACL authentication when connecting to Redis 6, just pass both
username
andpassword
to connection parameters and Predis switches to using the augmented variant ofAUTH
:// When using an URI string for parameters: $client = new Predis\Client('tcp://127.0.0.1?username=myuser&password=mypassword'); // When using a named array for parameters: $client = new Predis\Client([ 'username' => 'myuser', 'password' => 'mypassword', ]);
As usual Redis servers protected only by a password can still be accessed with just the
password
parameter. See the Redis documentation for more details about Redis ACLs. -
FIX:
NULL
or zero-length string values inpassword
anddatabase
do not trigger spuriousAUTH
andSELECT
commands anymore when connecting to Redis.// Won't trigger `AUTH` and `SELECT`: $client = new Predis\Client('tcp://127.0.0.1?password=&database='); // Won't trigger `AUTH` and `SELECT`: $client = new Predis\Client([ 'password' => null, 'database' => '', ]);
This fix addresses some old issues with certain libraries and frameworks (see ISSUE #436).
Empty connection parameters do not make much sense anyway so, in the next major release, any field containing
NULL
or a zero-length string will be stripped away when converting URI strings and named arrays to instances ofPredis\Connection\Parameters
. -
FIX:
SORT
now always triggers a switch to the master node in replication configurations instead of just when theSTORE
modifier is specified. The reason for this change is thatSORT
is always considered to be a write operation and it actually fails with a-READONLY
error response when executed against a replica node (ISSUE #554). -
FIX: using
foreach()
on a client instance when it is connected to a single Redis server does not throw an exception anymore but the iteration will run for just one loop returning a new client for the underlying single-node connection (ISSUE #552, PR #556).$client = new Predis\Client('tcp://127.0.0.1'); foreach ($client as $clientNode) { // Iterates just once, does not throw an exception anymore. }
Using
foreach()
actually makes sense when using aggregate connection backends for client-side sharding orredis-cluster
but there is no reason (and it is wrong anyway) to throw an exception inPredis\Client::getIterator()
when the client is connected to a single server. -
FIX:
Predis\Cluster\Distributor\HashRing::addNodeToRing()
was calculating the hash required for distribution by usingcrc32()
directly instead of the methodPredis\Cluster\Hash\HashGeneratorInterface::hash()
implemented by the class itself. This fix does not have any impact on existing cluster deployments using client-side sharding based on this distributor simply because it does not take any external hash generators so distribution is not going to be affected. -
Improved
@method
annotations for methods responding to Redis commands defined byPredis\ClientInterface
andPredis\ClientContextInterface
(PR #456 and PR #497, other fixes applied after further analysys).