Repository navigation
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)
- feat(php): add SISMEMBER XX support via sIsMemberIfExists by @leslie-bq in #402
- feat(php): add sharded pub/sub (SSUBSCRIBE, SUNSUBSCRIBE, SPUBLISH) to cluster client by @rlunar in #341
- feat(php): add DELIFEQ command support by @prateek-kumar-improving in #377
- feat(php): support PHPRedis OPT_SLAVE_FAILOVER on ValkeyGlideCluster by @uintaam in #359
- feat(php): add PHPRedis-compatible OPT_PREFIX and _prefix() key prefixing by @uintaam in #348
- feat(php): add ValkeyGlide::pconnect() by @uintaam in #353
- feat(php): reuse persistent clients across requests (persistent_id / $persistent) by @uintaam in #352
- feat(php): cap the pub/sub subscriber queue at 10,000 messages / 64 MiB by @uintaam in #365
- feat(php): add HGETDEL command support by @prateek-kumar-improving in #343
- feat(php): add READ_FROM_AZ_AFFINITY_ALL_NODES read strategy by @prateek-kumar-improving in #335
- feat(php): add lib_name and client_info_tag to client configuration by @Jonathan-Improving in #292
- feat(php): implement PUBSUB SHARDCHANNELS by @prateek-kumar-improving in #327
- feat(standalone): add NodeDiscoveryMode support for standalone clients by @prateek-kumar-improving in #322
- feat(config): add mTLS (mutual TLS) client certificate support by @prateek-kumar-improving in #321
- feat(php): implement CONFIG command with routing for cluster by @prateek-kumar-improving in #320
- feat(php): Implement monitor command by @prateek-kumar-improving in #309
- feat(php): Implement lolwut command by @prateek-kumar-improving in #314
- feat(php): implement LASTSAVE command by @prateek-kumar-improving in #315
- feat(php): implement CLIENT TRACKINGINFO command by @prateek-kumar-improving in #293
- Add MUSL support by @prateek-kumar-improving in #291
- Implement LATENCY HISTORY, LATEST, and RESET commands by @prateek-kumar-improving in #283
- Implement MEMORY DOCTOR, MALLOC-STATS, PURGE, and STATS commands by @prateek-kumar-improving in #285
- Implement failover and replicaof command by @prateek-kumar-improving in #282
- Add circuit breaker configuration support by @jeremyprime in #277
- Implement migrate command by @prateek-kumar-improving in #276
- Implement client Pause and Unpause command by @prateek-kumar-improving in #274
- Implement reset command by @prateek-kumar-improving in #273
- Implement save command by @prateek-kumar-improving in #272
- PHP: Implement bgwriteaof command by @prateek-kumar-improving in #271
- PHP: Implement getLastError() and clearLastError() for PHPRedis compatibility by @tnucera in #221
- feat(php): implement BGSAVE, BGSAVE SCHEDULE, and BGSAVE CANCEL commands by @prateek-kumar-improving in #237
Fixes (24)
- fix(php): fix issues from the rc2 bug bash by @prateek-kumar-improving in #442
- fix(logger): logger creation returns false instead of crashing when logfile unwritable by @leslie-bq in #445
- fix(php): return false for missing fields from hGetEx() by @uintaam in #417
- fix(php): send float arguments without rounding them to six digits by @uintaam in #418
- fix(php): queue rawcommand() in multi() and pipeline() by @uintaam in #419
- fix(php): free queued result state when a batch is not executed by @uintaam in #416
- fix(php): handle hRandField() options and replies as PHPRedis does by @uintaam in #422
- fix(php): size zset argument buffers and stop double frees in zAdd() by @uintaam in #411
- fix(php): keep hGetEx() arguments alive until exec() in a batch by @uintaam in #412
- fix(php): record rawcommand() errors for getLastError() by @uintaam in #410
- fix(php): return false from dbSize() and pExpireTime() when the command fails by @uintaam in #409
- fix(php): fix memory-safety bugs in SORT, FCALL, list push, HRANDFIELD by @prateek-kumar-improving in #425
- fix(php): free an address resolver when its client is closed, not at request shutdown by @uintaam in #397
- fix(php): use the PHPRedis value 8 for OPT_REPLY_LITERAL by @uintaam in #358
- fix(php): stop sending a 0-second periodic check interval for cluster clients by @uintaam in #355
- fix(php): apply an integer timeout passed to connect() by @uintaam in #356
- fix(php): require TLS for IAM auth by @jeremyprime in #391
- fix(php): send empty-string keys, values and members to the server by @uintaam in #393
- fix(php): only run the PHP address resolver on the PHP thread by @uintaam in #357
- fix(php): queue EVAL and FUNCTION LOAD in batches, fix empty EXEC and FUNCTION LOAD REPLACE by @uintaam in #347
- fix(php): do not close or use clients inherited through fork() by @uintaam in #351
- fix(php): make the pub/sub push callback thread-safe by @uintaam in #364
- fix(php): release pub/sub registry per request, guard cluster re-construct, check NULL connection response, forbid clone, init varargs by @uintaam in #350
- fix(compatibility): track getLastError/clearLastError as missing PHPRedis methods by @tnucera in #220
Tests, CI, docs and maintenance (21)
- ci: stabilize PHP setup in build-php-wrapper on Ubuntu by @leslie-bq in #452
- test(php): use a non-shared integer in the OBJECT refcount test by @leslie-bq in #449
- test(php): skip cluster SORT GET patterns test on Valkey < 8.0 by @leslie-bq in #447
- cleanup: Issue templates ask for PHP version only instead of other languages that don't apply by @leslie-bq in #434
- ci: fix the nightly full matrix (startup failure, ARM64 runners, LOLWUT test) by @uintaam in #408
- ci: install PHP from packages.sury.org and move pinned jobs to ubuntu-26.04 by @uintaam in #386
- test: improve test stability and cluster test isolation by @Big-Shark in #340
- test(php): give test clients a 2 s connection timeout by @uintaam in #396
- test(php): wait for BGSAVE on replicas before CANCEL in cluster tests by @uintaam in #389
- ci: pin ubuntu-latest jobs to ubuntu-24.04 by @nderraugh in #390
- test(php): fix flaky testExists and testFailoverSucceeds by @uintaam in #376
- docs(php): fix AGENTS.md build/test commands and stale template text by @jeremyprime in #370
- test(php): Improve stability of PubSub tests, add 5-time default retry for apt-get, pin Pluggy and Scancode version by @leslie-bq in #372
- test(php): verify Valkey 9.2 INFO fields, config values and client flags by @currantw in #354
- ci(php): test against Valkey 9.2.0-rc1 by @currantw in #346
- ci(php): add PHP 8.4 and 8.5 to the supported versions matrix by @Big-Shark in #339
- ci(ort): fix attribution build (ORT 59.0.0) by @prateek-kumar-improving in #336
- Update submodule glide core by @prateek-kumar-improving in #325
- Update dependencies in readme.md by @prateek-kumar-improving in #290
- PHP: Fix version in workflow files by @prateek-kumar-improving in #260
- PHP: fix ort workflow to verify signatures by @prateek-kumar-improving in #255
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