Key Features
- Alpine Linux (musl) Support: The extension now builds and runs on Alpine Linux 3.19+ (x86_64 and aarch64).
- PHP 8.4 and 8.5: Added PHP 8.4 and 8.5 to the supported versions and the CI test matrix.
- Persistent Clients: Added persistent clients for PHP-FPM and other long-lived workers.
connect(persistent_id: ...),ValkeyGlide::pconnect()andnew ValkeyGlideCluster(persistent: true)keep the client open after the request and reuse it in later requests with the same configuration, so the connection (and, for clusters, topology discovery) is not repeated on every request. The new ini settingvalkey_glide.max_persistent_clients(default 32) caps the number of kept clients per process (per thread under ZTS). - PHPRedis Key Prefixing: Added
OPT_PREFIX(throughsetOption()/getOption()) and_prefix()for standalone and cluster clients. The prefix is applied to every key argument, including multi-key commands, script and function keys, commands queued inmulti()/pipeline(), pub/sub channels, and the key that routes a cluster command.OPT_SCANis now a PHPRedis-style bitmask (SCAN_PREFIX/SCAN_NOPREFIX,SCAN_RETRY/SCAN_NORETRY). - Mutual TLS (mTLS): Added client certificate support for standalone and cluster clients through
advanced_config['tls_config'], either as bytes (client_cert/client_key) or as file paths (client_cert_path/client_key_path) with automatic certificate reloading (cert_reload_interval_seconds). - Sharded Pub/Sub for Cluster Clients: Added
ssubscribe(),sunsubscribe(),spublish(),pubsub('shardnumsub', [...])andPUBSUB SHARDCHANNELStoValkeyGlideCluster. These previously threw "not yet supported". - AZ Affinity All Nodes Read Strategy: Added
READ_FROM_AZ_AFFINITY_ALL_NODES, which serves reads from any node, primary or replica, in the client's availability zone. OPT_SLAVE_FAILOVERfor Clusters:ValkeyGlideCluster::setOption()/getOption()supportFAILOVER_NONE,FAILOVER_ERROR,FAILOVER_DISTRIBUTEandFAILOVER_DISTRIBUTE_SLAVES, mapped to the matching GLIDE read strategy.- Node Discovery Mode: Added
NodeDiscoveryMode(STANDARD,STATIC,DISCOVER_ALL) for standalone clients. - Circuit Breaker Configuration: Added circuit breaker configuration support.
- Client Identification: Added
lib_nameandclient_info_tagto the client configuration. - New Valkey Commands: Added
DELIFEQ(Valkey 9.0),HGETDEL(Valkey 9.1) andSISMEMBER XXthroughsIsMemberIfExists()(Valkey 9.2). Also addedBGSAVE(includingSCHEDULEandCANCEL),BGREWRITEAOF,SAVE,LASTSAVE,RESET,CLIENT PAUSE/UNPAUSE,CLIENT TRACKINGINFO,MIGRATE,FAILOVER,REPLICAOF,MONITOR,LOLWUT,CONFIGfor cluster clients,LATENCY HISTORY/LATEST/RESET, andMEMORY DOCTOR/MALLOC-STATS/PURGE/STATS. - PHPRedis Compatibility Methods: Added
getLastError()andclearLastError(). - Memory-Safety and PHPRedis-Parity Fixes: Fixed heap corruption, double frees, use-after-free and out-of-bounds writes in many commands (
zAdd(),sort(),fcall(), list pushes,hRandField(),hGetEx(),del()/unlink(),zRandMember(),dbSize(),pExpireTime()and others), plus crashes in pub/sub, address resolver, OpenTelemetry configuration andfork()handling. The PHPRedis-parity changes below are listed under Migration Changes, each with migration steps.
Migration Changes
These changes bring the client closer to PHPRedis behavior or close safety gaps. Each item lists what changed and how to adjust.
- Cluster reads default to primaries.
ValkeyGlideClusterconstructed with PHPRedis-style parameters ($seeds,$auth, ...) now reads from primaries whenread_fromis not given, matching PHPRedisRedisCluster. It previously defaulted toREAD_FROM_PREFER_REPLICA(#369).- Migration: to keep replica reads, pass
read_from: ValkeyGlide::READ_FROM_PREFER_REPLICA, or setOPT_SLAVE_FAILOVERtoFAILOVER_DISTRIBUTE_SLAVES.
- Migration: to keep replica reads, pass
- AZ-affinity strategies require
client_az.READ_FROM_AZ_AFFINITY,READ_FROM_AZ_AFFINITY_REPLICAS_AND_PRIMARYandREAD_FROM_AZ_AFFINITY_ALL_NODESconfigured without a validclient_aznow throw at client creation. Before, the core logged a warning and downgraded the strategy toPreferReplica. Aclient_azthat is empty, whitespace-only, contains a NUL byte, or has leading or trailing whitespace is rejected (#316).- Migration: set
client_azto the availability zone name, with no surrounding whitespace. If you do not want AZ-aware reads, choose another read strategy such asREAD_FROM_PREFER_REPLICA.
- Migration: set
- IAM authentication requires TLS. Configuring IAM auth without TLS is rejected at client creation instead of sending the token over a plaintext connection (#391).
- Migration: enable TLS in the client configuration of every client that uses IAM auth.
zRem()andzMscore()convert members likezAdd(). Non-string members are converted with PHP's string conversion, as PHPRedis does.zRem($key, false)now removes the member""instead of"0", andzRem($key, 1.23456789)removes"1.23456789"instead of"1.23457"(#380).- Migration: to match a member stored in the old form, pass that string, for example
zRem($key, '0').
- Migration: to match a member stored in the old form, pass that string, for example
- Floats are no longer rounded to six significant digits. Values, members and fields are converted as PHP converts floats to strings, and numbers a command takes as a double are sent in the shortest form that reads back as the same double (#382).
- Migration: if you relied on the rounding, round the value yourself before the call, for example with
round()orsprintf('%.6g', $value). Members stored from a rounded float must be addressed with the stored string.
- Migration: if you relied on the rounding, round the value yourself before the call, for example with
hGetEx()returnsfalsefor a missing field. It returnednull, and now matcheshMget(),hGetDel()and PHPRedis (#415).- Migration: replace
=== nullandis_null()checks onhGetEx()results with=== false.
- Migration: replace
hRandField()follows PHPRedis return shapes (#421, #443):count => 1returns an array, as every other count does. It returned a single field as a string.count => 0means no count: it returns a single field, or one field => value pair withWITHVALUES. It returnedfalse.- Option keys are case-insensitive, and
WITHVALUEScan be passed as a plain value (['WITHVALUES']). Both were ignored before. - A missing hash with a count or
WITHVALUESreturns[]instead offalse. - With
withvalues, numeric field names are returned as integer array keys ('7'becomes7). - Migration: read the first element of the array when you pass
count => 1, test for an empty array instead offalseon a missing hash, and compare field names with loose equality or cast them to strings where you used strict string comparison.
object()accepts only four subcommands. It sendsREFCOUNT,IDLETIME,FREQandENCODING, matched exactly and case-insensitively. Any other subcommand, includingHELPand prefixes such asREF, emits the warning "Invalid subcommand sent to OBJECT" and returnsfalsewithout sending anything. Before, the key was sent as the command name, soobject('HELP', 'FLUSHDB')flushed the database (#443).- Migration: use the full subcommand name. For
OBJECT HELPor other subcommands, userawcommand().
- Migration: use the full subcommand name. For
xAdd()withmaxlen0 no longer trims the stream.MAXLENis sent only when it is positive. Before,MAXLEN 0emptied the stream (#443).- Migration: to empty a stream,
del()the key or trim it explicitly withxTrim().
- Migration: to empty a stream,
OPT_REPLY_LITERALis now 8, as in PHPRedis. It was 1, the PHPRedis value ofOPT_SERIALIZER. Option 1 still accepts a bool for reply literals but is deprecated (#368).- Migration: use the
ValkeyGlide::OPT_REPLY_LITERALconstant instead of a literal1. PHPRedis code that sets a serializer no longer turns on reply literals by accident.
- Migration: use the
- Batch behavior changed.
rawcommand(),eval(),evalSha(),eval_ro(),evalsha_ro()andfunctionLoad()insidemulti()orpipeline()are now queued with the batch and return the client, instead of running immediately outside it.exec()after an emptymulti()orpipeline()returns[]and leaves batch mode instead of returningfalse(#347, #413).- Migration: read results of these commands from the array that
exec()returns. Move a command out of the batch if you need its result immediately. Checkexec()for an empty array instead offalse. In a batch,rawcommand()refuses node routes and the commands SELECT, AUTH, HELLO, CLIENT SETNAME and RESET (it returnsfalse).
- Migration: read results of these commands from the array that
- Constructing and cloning clients.
ValkeyGlideCluster::__construct()on an already connected object throws instead of replacing the client, andcloneon aValkeyGlideorValkeyGlideClusterobject throws anError(#350).- Migration: create a new object instead of calling the constructor again or cloning.
- Clients inherited through
fork(). The child no longer closes an inherited client. Calling a method on it in the child throwsValkeyGlideException, exceptclose(),getLastError(),clearLastError(),getOption()andsetOption()(#351).- Migration: do not use a parent's client in a forked child. Run GLIDE commands in the parent, or create the client in the child. Creating a new client in a child after the parent has used GLIDE can still crash or hang until the core is fixed.
- Pub/sub subscribers have a bounded queue. Each subscriber queues at most 10,000 messages or 64 MiB of payload. A single larger message is still delivered when the queue is empty. When a slow callback falls behind, newer messages are dropped and a warning with the drop count is logged, at most once per second. Before, every message was queued with no limit (#363, #365).
- Migration: keep subscriber callbacks fast, for example by handing messages to a queue or worker. Watch the logs for the drop warning. The limits are fixed and not configurable.
New Requirements
- Building from source now needs the protobuf-c library and compiler (
libprotobuf-c-dev,protobuf-c-compiler),libffidevelopment headers,python3andcbindgen(cargo install cbindgen). See the README for per-distribution package lists.
What's Changed
The curated, user-facing list of every change in this release is in CHANGELOG.md. Pull requests are listed below by category. Dependabot and other bot updates are omitted.
Features (31)
Fixes (24)
Tests, CI, docs and maintenance (21)
New Contributors
- @jeremyprime made their first contribution
- @Jonathan-Improving made their first contribution
- @uintaam made their first contribution
- @tnucera made their first contribution
- @Big-Shark made their first contribution
- @rlunar made their first contribution
- @nderraugh made their first contribution
- @leslie-bq made their first contribution
Full Changelog: v1.1.2...v1.2.0