diff --git a/CHANGELOG.md b/CHANGELOG.md index fcfb5e7607..f272e5fef3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,11 @@ # Changelog -All changes to phpredis will be documented in this file. +All changes to valkey-php will be documented in this file. We're basing this format on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and PhpRedis adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +and PhpValkey adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -# [6.2.0] - 2025-03-24 ([Github](https://github.com/phpredis/phpredis/releases/6.2.0), [PECL](https://pecl.php.net/package/redis/6.2.0)) +# [6.2.0] - 2025-03-24 ([Github](https://github.com/valkey-php/valkey-php/releases/6.2.0), [PECL](https://pecl.php.net/package/redis/6.2.0)) ### Sponsors :sparkling_heart: @@ -23,176 +23,176 @@ and PhpRedis adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ## Fixed - Fix arguments order for `SET` command - [f73f5fc](https://github.com/phpredis/phpredis/commit/f73f5fcce55ab9268c4eb40bf93cccdae418c1d2) + [f73f5fc](https://github.com/valkey-php/valkey-php/commit/f73f5fcce55ab9268c4eb40bf93cccdae418c1d2) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Fix error length calculation and UB sanity check - [e73130fe](https://github.com/phpredis/phpredis/commit/e73130fee0c22a20e11ce1596579df3f6f826974) + [e73130fe](https://github.com/valkey-php/valkey-php/commit/e73130fee0c22a20e11ce1596579df3f6f826974) ([michael-grunder](https://github.com/michael-grunder)) - Invalidate slot cache on failed cluster connections - [c7b87843](https://github.com/phpredis/phpredis/commit/c7b878431014789f35d2fb1834b95257ca6cbba5) + [c7b87843](https://github.com/valkey-php/valkey-php/commit/c7b878431014789f35d2fb1834b95257ca6cbba5) ([James Kennedy](https://github.com/jkenn99)) - Don't cast a uint64_t to a long - [faa4bc20](https://github.com/phpredis/phpredis/commit/faa4bc20868c76be4ecc4265015104a8adafccc4) + [faa4bc20](https://github.com/valkey-php/valkey-php/commit/faa4bc20868c76be4ecc4265015104a8adafccc4) ([michael-grunder](https://github.com/michael-grunder)) - Fix potential NULL dereference - [43e6cab8](https://github.com/phpredis/phpredis/commit/43e6cab8792dc01580894d85600add9b68c27a42) + [43e6cab8](https://github.com/valkey-php/valkey-php/commit/43e6cab8792dc01580894d85600add9b68c27a42) ([peter15914](https://github.com/peter15914)) - Print cursor as unsigned 64 bit integer - [138d07b6](https://github.com/phpredis/phpredis/commit/138d07b67c5537373834f1cae99804e092db1631) + [138d07b6](https://github.com/valkey-php/valkey-php/commit/138d07b67c5537373834f1cae99804e092db1631) ([Bentley O'Kane-Chase](https://github.com/bentleyo)) - Fix XAUTOCLAIM argc when sending COUNT - [0fe45d24](https://github.com/phpredis/phpredis/commit/0fe45d24d4d8c115a5b52846be072ecb9bb43329) + [0fe45d24](https://github.com/valkey-php/valkey-php/commit/0fe45d24d4d8c115a5b52846be072ecb9bb43329) ([michael-grunder](https://github.com/michael-grunder)) ### Added - Added `serverName()` and `serverVersion()` introspection methods - [056c2dbe](https://github.com/phpredis/phpredis/commit/056c2dbee7f6379a9f546e46584ace59449847c7) - [cbaf095f](https://github.com/phpredis/phpredis/commit/cbaf095ff708caf2728541bd627399a4058d0f19) - [fa3eb006](https://github.com/phpredis/phpredis/commit/fa3eb00683a2c8d539b52c0738db6821c74fef54) + [056c2dbe](https://github.com/valkey-php/valkey-php/commit/056c2dbee7f6379a9f546e46584ace59449847c7) + [cbaf095f](https://github.com/valkey-php/valkey-php/commit/cbaf095ff708caf2728541bd627399a4058d0f19) + [fa3eb006](https://github.com/valkey-php/valkey-php/commit/fa3eb00683a2c8d539b52c0738db6821c74fef54) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) ([michael-grunder](https://github.com/michael-grunder)) - Added `getWithMeta` method - [9036ffca](https://github.com/phpredis/phpredis/commit/9036ffca) + [9036ffca](https://github.com/valkey-php/valkey-php/commit/9036ffca) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Implement `GETDEL` command for RedisCluster - [d342e4ac](https://github.com/phpredis/phpredis/commit/d342e4ac18723607b001deb593c8d45e40bbc4c8) +- Implement `GETDEL` command for ValkeyCluster + [d342e4ac](https://github.com/valkey-php/valkey-php/commit/d342e4ac18723607b001deb593c8d45e40bbc4c8) ([michael-grunder](https://github.com/michael-grunder)) -- Introduce `Redis::OPT_PACK_IGNORE_NUMBERS` option - [f9ce9429](https://github.com/phpredis/phpredis/commit/f9ce9429ef9f14a3de2c3fe1d68d02fb7440093d) - [29e5cf0d](https://github.com/phpredis/phpredis/commit/29e5cf0d8c03069aa34c2a63322951fdf2c268c2) +- Introduce `Valkey::OPT_PACK_IGNORE_NUMBERS` option + [f9ce9429](https://github.com/valkey-php/valkey-php/commit/f9ce9429ef9f14a3de2c3fe1d68d02fb7440093d) + [29e5cf0d](https://github.com/valkey-php/valkey-php/commit/29e5cf0d8c03069aa34c2a63322951fdf2c268c2) ([michael-grunder](https://github.com/michael-grunder)) - Implement Valkey >= 8.1 `IFEQ` `SET` option - [a2eef77f](https://github.com/phpredis/phpredis/commit/a2eef77f4419cda815052e75def3af81b0ccd80f) + [a2eef77f](https://github.com/valkey-php/valkey-php/commit/a2eef77f4419cda815052e75def3af81b0ccd80f) ([michael-grunder](https://github.com/michael-grunder)) - Implement KeyDB's EXPIREMEMBER[AT] commands - [4cd3f593](https://github.com/phpredis/phpredis/commit/4cd3f59356582a65aec1cceed44741bd5d161d9e) + [4cd3f593](https://github.com/valkey-php/valkey-php/commit/4cd3f59356582a65aec1cceed44741bd5d161d9e) ([michael-grunder](https://github.com/michael-grunder)) - Set priority to 60 (for PIE installations) - [9e504ede](https://github.com/phpredis/phpredis/commit/9e504ede34749326a39f997db6cc5c4201f6a9bc) + [9e504ede](https://github.com/valkey-php/valkey-php/commit/9e504ede34749326a39f997db6cc5c4201f6a9bc) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) ### Documentation - Fix phpdoc type of `$pattern` - [5cad2076](https://github.com/phpredis/phpredis/commit/5cad20763710d44f8efb8e537f8f84a812935604) + [5cad2076](https://github.com/valkey-php/valkey-php/commit/5cad20763710d44f8efb8e537f8f84a812935604) ([OHZEKI Naoki](https://github.com/zeek0x)) -- Better documentation for the `$tlsOptions` parameter of RedisCluster - [8144db37](https://github.com/phpredis/phpredis/commit/8144db374338006a316beb11549f37926bd40c5d) +- Better documentation for the `$tlsOptions` parameter of ValkeyCluster + [8144db37](https://github.com/valkey-php/valkey-php/commit/8144db374338006a316beb11549f37926bd40c5d) ([Jacob Brown](https://github.com/JacobBrownAustin)) ### Tests/CI - Reorganize tests - [807f806f](https://github.com/phpredis/phpredis/commit/807f806f) + [807f806f](https://github.com/valkey-php/valkey-php/commit/807f806f) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Add details to the option doc block - [abb0f6cc](https://github.com/phpredis/phpredis/commit/abb0f6ccc827f240a1de53633225abbc2848fc3a) + [abb0f6cc](https://github.com/valkey-php/valkey-php/commit/abb0f6ccc827f240a1de53633225abbc2848fc3a) ([michael-grunder](https://github.com/michael-grunder)) - Update CodeQL to v3 - [41e11417](https://github.com/phpredis/phpredis/commit/41e114177a20a03e3013db2a3b90980a1f4f1635) - [a10bca35](https://github.com/phpredis/phpredis/commit/a10bca35bba32bb969cc1e473564695d3f8a8811) + [41e11417](https://github.com/valkey-php/valkey-php/commit/41e114177a20a03e3013db2a3b90980a1f4f1635) + [a10bca35](https://github.com/valkey-php/valkey-php/commit/a10bca35bba32bb969cc1e473564695d3f8a8811) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Add PHP 8.4 to CI - [6097e7ba](https://github.com/phpredis/phpredis/commit/6097e7ba50c0a300bc4f420f84c5d2665ef99d90) + [6097e7ba](https://github.com/valkey-php/valkey-php/commit/6097e7ba50c0a300bc4f420f84c5d2665ef99d90) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Pin ubuntu version for KeyDB - [eb66fc9e](https://github.com/phpredis/phpredis/commit/eb66fc9e2fe60f13e5980ea2ecbe9457ca5ae8b4) - [985b0313](https://github.com/phpredis/phpredis/commit/985b0313fb664c9776c3d2c84e778ddd6733728e) + [eb66fc9e](https://github.com/valkey-php/valkey-php/commit/eb66fc9e2fe60f13e5980ea2ecbe9457ca5ae8b4) + [985b0313](https://github.com/valkey-php/valkey-php/commit/985b0313fb664c9776c3d2c84e778ddd6733728e) ([michael-grunder](https://github.com/michael-grunder)) - Windows CI: update setup-php-sdk to v0.10 and enable caching - [f89d4d8f](https://github.com/phpredis/phpredis/commit/f89d4d8f6eecbe223e158651ffffd77ffa27449b) + [f89d4d8f](https://github.com/valkey-php/valkey-php/commit/f89d4d8f6eecbe223e158651ffffd77ffa27449b) ([Christoph M. Becker](https://github.com/cmb69)) ### Internal/Performance - Reduce buffer size for signed integer - [044b3038](https://github.com/phpredis/phpredis/commit/044b30386f0418e9ed2a2bbc3b79582520d008d8) - [35c59880](https://github.com/phpredis/phpredis/commit/35c5988027eda663167a64decde4512957cae738) + [044b3038](https://github.com/valkey-php/valkey-php/commit/044b30386f0418e9ed2a2bbc3b79582520d008d8) + [35c59880](https://github.com/valkey-php/valkey-php/commit/35c5988027eda663167a64decde4512957cae738) ([Bentley O'Kane-Chase](https://github.com/bentleyo)) - Create a strncmp wrapper - [085d61ec](https://github.com/phpredis/phpredis/commit/085d61ecfb0d484832547b46343a2e4b275a372e) + [085d61ec](https://github.com/valkey-php/valkey-php/commit/085d61ecfb0d484832547b46343a2e4b275a372e) ([michael-grunder](https://github.com/michael-grunder)) - Refactor and avoid allocation in rawcommand method - [f68544f7](https://github.com/phpredis/phpredis/commit/f68544f70385e1d431fb0245fafe30b39ee7479a) + [f68544f7](https://github.com/valkey-php/valkey-php/commit/f68544f70385e1d431fb0245fafe30b39ee7479a) ([JakubOnderka](https://github.com/JakubOnderka)) - Switch from linked list to growing array for reply callbacks - [a551fdc9](https://github.com/phpredis/phpredis/commit/a551fdc94c14d7974f2303cd558f7bd3e0fd91d6) - [42a42769](https://github.com/phpredis/phpredis/commit/42a427695e89577a1f1a554dba268527f3995708) + [a551fdc9](https://github.com/valkey-php/valkey-php/commit/a551fdc94c14d7974f2303cd558f7bd3e0fd91d6) + [42a42769](https://github.com/valkey-php/valkey-php/commit/42a427695e89577a1f1a554dba268527f3995708) ([JakubOnderka](https://github.com/JakubOnderka)) ([michael-grunder](https://github.com/michael-grunder)) - Reuse redis_sock_append_auth method - [be388562](https://github.com/phpredis/phpredis/commit/be388562058a75ed8fd31926bb0e6a60e2d8cb08) + [be388562](https://github.com/valkey-php/valkey-php/commit/be388562058a75ed8fd31926bb0e6a60e2d8cb08) ([JakubOnderka](https://github.com/JakubOnderka)) - Switch pipeline_cmd from smart_str to smart_string - [571ffbc8](https://github.com/phpredis/phpredis/commit/571ffbc8e0a5da807a6cc4a2cc5aa90af72e23b0) + [571ffbc8](https://github.com/valkey-php/valkey-php/commit/571ffbc8e0a5da807a6cc4a2cc5aa90af72e23b0) ([JakubOnderka](https://github.com/JakubOnderka)) - Remove unused redis_debug_response method from library.c - [7895636a](https://github.com/phpredis/phpredis/commit/7895636a3a7cd3cad396a83ebe3aa5fe0208f42d) + [7895636a](https://github.com/valkey-php/valkey-php/commit/7895636a3a7cd3cad396a83ebe3aa5fe0208f42d) ([JakubOnderka](https://github.com/JakubOnderka)) - Optimise HMGET method - [2434ba29](https://github.com/phpredis/phpredis/commit/2434ba294cbb3b2f5b4ee581c37056906902d0d9) + [2434ba29](https://github.com/valkey-php/valkey-php/commit/2434ba294cbb3b2f5b4ee581c37056906902d0d9) ([JakubOnderka](https://github.com/JakubOnderka)) - Avoid unnecessary allocation in redis_hset_cmd - [aba09933](https://github.com/phpredis/phpredis/commit/aba09933db05a1a36e947c6fa9dca9889c6a77ff) + [aba09933](https://github.com/valkey-php/valkey-php/commit/aba09933db05a1a36e947c6fa9dca9889c6a77ff) ([JakubOnderka](https://github.com/JakubOnderka)) - Avoid unnecessary allocation in redis_hdel_cmd - [4082dd07](https://github.com/phpredis/phpredis/commit/4082dd07f714fd2f6a0918b1845eb46c403a9edd) + [4082dd07](https://github.com/valkey-php/valkey-php/commit/4082dd07f714fd2f6a0918b1845eb46c403a9edd) ([JakubOnderka](https://github.com/JakubOnderka)) - Avoid unnecessary allocation in redis_key_varval_cmd - [99650e15](https://github.com/phpredis/phpredis/commit/99650e15453f03b5dd99284548514551fde4c812) + [99650e15](https://github.com/valkey-php/valkey-php/commit/99650e15453f03b5dd99284548514551fde4c812) ([JakubOnderka](https://github.com/JakubOnderka)) - Use zval_get_tmp_string method that is faster when provided zval is string - [f6906470](https://github.com/phpredis/phpredis/commit/f6906470a52e2d24b1e1b9f2574726643edd7a64) + [f6906470](https://github.com/valkey-php/valkey-php/commit/f6906470a52e2d24b1e1b9f2574726643edd7a64) ([JakubOnderka](https://github.com/JakubOnderka)) -- Optimise constructing Redis command string - [2a2f908f](https://github.com/phpredis/phpredis/commit/2a2f908f2b6b695a0e6705200160e592802f0e41) +- Optimise constructing Valkey command string + [2a2f908f](https://github.com/valkey-php/valkey-php/commit/2a2f908f2b6b695a0e6705200160e592802f0e41) ([JakubOnderka](https://github.com/JakubOnderka)) - If no command is issued in multi mode, return immutable empty array - [5156e032](https://github.com/phpredis/phpredis/commit/5156e0320242ff05f327a3801667140069688c0e) + [5156e032](https://github.com/valkey-php/valkey-php/commit/5156e0320242ff05f327a3801667140069688c0e) ([JakubOnderka](https://github.com/JakubOnderka)) - Test for empty pipeline and multi - [426de2bb](https://github.com/phpredis/phpredis/commit/426de2bb71372f665f5a5bb5a779a7b9c586892d) + [426de2bb](https://github.com/valkey-php/valkey-php/commit/426de2bb71372f665f5a5bb5a779a7b9c586892d) ([JakubOnderka](https://github.com/JakubOnderka)) - Optimise method array_zip_values_and_scores - [400503b8](https://github.com/phpredis/phpredis/commit/400503b8718104b766ceb4a0b84e4a446dbee09b) + [400503b8](https://github.com/valkey-php/valkey-php/commit/400503b8718104b766ceb4a0b84e4a446dbee09b) ([JakubOnderka](https://github.com/JakubOnderka)) - Faster parameter parsing in redis_key_cmd and redis_key_long_val_cmd - [83a19656](https://github.com/phpredis/phpredis/commit/83a19656f49aec8f354596099dbf97ba7375d7af) + [83a19656](https://github.com/valkey-php/valkey-php/commit/83a19656f49aec8f354596099dbf97ba7375d7af) ([JakubOnderka](https://github.com/JakubOnderka)) -- Use immutable empty array in Redis::hKeys - [3a2f3f45](https://github.com/phpredis/phpredis/commit/3a2f3f45fc7bb01d1be2b9d97cf9d8bff0b0e818) +- Use immutable empty array in Valkey::hKeys + [3a2f3f45](https://github.com/valkey-php/valkey-php/commit/3a2f3f45fc7bb01d1be2b9d97cf9d8bff0b0e818) ([JakubOnderka](https://github.com/JakubOnderka)) -- Use immutable empty array in Redis::exec - [60b5a886](https://github.com/phpredis/phpredis/commit/60b5a8860ae3ff2d02d7f06cc6f86b59cb53b2cf) +- Use immutable empty array in Valkey::exec + [60b5a886](https://github.com/valkey-php/valkey-php/commit/60b5a8860ae3ff2d02d7f06cc6f86b59cb53b2cf) ([JakubOnderka](https://github.com/JakubOnderka)) - Do not allocate empty string or string with one character - [64da891e](https://github.com/phpredis/phpredis/commit/64da891e6fe5810b1aa2a47bc0632a2cd346659d) + [64da891e](https://github.com/valkey-php/valkey-php/commit/64da891e6fe5810b1aa2a47bc0632a2cd346659d) ([JakubOnderka](https://github.com/JakubOnderka)) - Initialize arrays with known size - [99beb922](https://github.com/phpredis/phpredis/commit/99beb9221c815018f1d076654b033cafac22a6ce) + [99beb922](https://github.com/valkey-php/valkey-php/commit/99beb9221c815018f1d076654b033cafac22a6ce) ([JakubOnderka](https://github.com/JakubOnderka)) - Use smart str for constructing pipeline cmd - [b665925e](https://github.com/phpredis/phpredis/commit/b665925eeddfdf6a6fc1de471c0789ffb60cd067) + [b665925e](https://github.com/valkey-php/valkey-php/commit/b665925eeddfdf6a6fc1de471c0789ffb60cd067) ([JakubOnderka](https://github.com/JakubOnderka)) -## [6.1.0] - 2024-10-04 ([Github](https://github.com/phpredis/phpredis/releases/6.1.0), [PECL](https://pecl.php.net/package/redis/6.1.0)) +## [6.1.0] - 2024-10-04 ([Github](https://github.com/valkey-php/valkey-php/releases/6.1.0), [PECL](https://pecl.php.net/package/redis/6.1.0)) **NOTE**: There were no changes to C code between 6.1.0RC2 and 6.1.0. ### Documentation - Update package.xml to make it clearer that we support many key-value stores - [52e69ede](https://github.com/phpredis/phpredis/commit/52e69ede) + [52e69ede](https://github.com/valkey-php/valkey-php/commit/52e69ede) ([Remi Collet](https://github.com/remicollet)) - Fix redis.io urls - [0bae4bb0](https://github.com/phpredis/phpredis/commit/0bae4bb0) + [0bae4bb0](https://github.com/valkey-php/valkey-php/commit/0bae4bb0) ([Vincent Langlet](https://github.com/VincentLanglet)) ### Tests/CI - Fix 2 tests with redis 6.2 - [cc1be322](https://github.com/phpredis/phpredis/commit/cc1be322) + [cc1be322](https://github.com/valkey-php/valkey-php/commit/cc1be322) ([Remi Collet](https://github.com/remicollet)) ### Sponsors :sparkling_heart: @@ -232,308 +232,308 @@ and PhpRedis adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm [@VincentLanglet](https://github.com/VincentLanglet) -## [6.1.0RC2] - 2024-09-23 ([Github](https://github.com/phpredis/phpredis/releases/6.1.0RC2), [PECL](https://pecl.php.net/package/redis/6.1.0RC2)) +## [6.1.0RC2] - 2024-09-23 ([Github](https://github.com/valkey-php/valkey-php/releases/6.1.0RC2), [PECL](https://pecl.php.net/package/redis/6.1.0RC2)) ### Fixed - Fixed a `SIGABRT` error in PHP 8.4 - [a75a7e5a](https://github.com/phpredis/phpredis/commit/a75a7e5a) + [a75a7e5a](https://github.com/valkey-php/valkey-php/commit/a75a7e5a) ([Michael Grunder](https://github.com/michael-grunder)) - Clean up code for unsupported versions of PHP - [37cebdd7](https://github.com/phpredis/phpredis/commit/37cebdd7) + [37cebdd7](https://github.com/valkey-php/valkey-php/commit/37cebdd7) ([Remi Collet](https://github.com/remicollet)) - Add `SessionHelpers.php` to `package.xml` - [e9474b80](https://github.com/phpredis/phpredis/commit/e9474b80) + [e9474b80](https://github.com/valkey-php/valkey-php/commit/e9474b80) ([Remi Collet](https://github.com/remicollet)) - 8.4 implicit null fix, bump version - [bff3a22e](https://github.com/phpredis/phpredis/commit/bff3a22e) - [30c8f90c](https://github.com/phpredis/phpredis/commit/30c8f90c) + [bff3a22e](https://github.com/valkey-php/valkey-php/commit/bff3a22e) + [30c8f90c](https://github.com/valkey-php/valkey-php/commit/30c8f90c) ([Remi Collet](https://github.com/remicollet)) ### Changed - Raised minimum supported PHP version to 7.4 - [8b519423](https://github.com/phpredis/phpredis/commit/8b519423) + [8b519423](https://github.com/valkey-php/valkey-php/commit/8b519423) ([Michael Grunder](https://github.com/michael-grunder)) ### Removed - Removed erroneously duplicated changelog entries - [40c89736](https://github.com/phpredis/phpredis/commit/40c89736) + [40c89736](https://github.com/valkey-php/valkey-php/commit/40c89736) ([Michael Grunder](https://github.com/michael-grunder)) ### Tests/CI - Move to upload artifacts v4 - [9d3805009](https://github.com/phpredis/phpredis/commit/9d3805009) + [9d3805009](https://github.com/valkey-php/valkey-php/commit/9d3805009) ([Michael Grunder](https://github.com/michael-grunder)) ### Added - Added `composer.json` to support [PIE](https://github.com/php/pie) (PHP Installer for Extensions) - [b59e35a6](https://github.com/phpredis/phpredis/commit/b59e35a6) + [b59e35a6](https://github.com/valkey-php/valkey-php/commit/b59e35a6) ([James Titcumb](https://github.com/asgrim)) -## [6.1.0RC1] - 2024-08-04 ([GitHub](https://github.com/phpredis/phpredis/releases/6.1.0RC1), [PECL](https://pecl.php.net/package/redis/6.1.0RC1)) +## [6.1.0RC1] - 2024-08-04 ([GitHub](https://github.com/valkey-php/valkey-php/releases/6.1.0RC1), [PECL](https://pecl.php.net/package/redis/6.1.0RC1)) ### Fixed -- Fix random connection timeouts with Redis Cluster. - [eb7f31e7](https://github.com/phpredis/phpredis/commit/eb7f31e7) +- Fix random connection timeouts with Valkey Cluster. + [eb7f31e7](https://github.com/valkey-php/valkey-php/commit/eb7f31e7) ([Jozsef Koszo](https://github.com/kjoe)) - [#1142](https://github.com/phpredis/phpredis/pull/1142) - [#1385](https://github.com/phpredis/phpredis/pull/1385) - [#1633](https://github.com/phpredis/phpredis/pull/1633) - [#1707](https://github.com/phpredis/phpredis/pull/1707) - [#1811](https://github.com/phpredis/phpredis/pull/1811) - [#2407](https://github.com/phpredis/phpredis/pull/2407) + [#1142](https://github.com/valkey-php/valkey-php/pull/1142) + [#1385](https://github.com/valkey-php/valkey-php/pull/1385) + [#1633](https://github.com/valkey-php/valkey-php/pull/1633) + [#1707](https://github.com/valkey-php/valkey-php/pull/1707) + [#1811](https://github.com/valkey-php/valkey-php/pull/1811) + [#2407](https://github.com/valkey-php/valkey-php/pull/2407) - Fix argument count issue in HSET with associative array - [6ea5b3e0](https://github.com/phpredis/phpredis/commit/6ea5b3e0) + [6ea5b3e0](https://github.com/valkey-php/valkey-php/commit/6ea5b3e0) ([Viktor Djupsjöbacka](https://github.com/crocodele)) - SRANDMEMBER can return any type because of serialization. - [6673b5b2](https://github.com/phpredis/phpredis/commit/6673b5b2) + [6673b5b2](https://github.com/valkey-php/valkey-php/commit/6673b5b2) ([michael-grunder](https://github.com/michael-grunder)) - Fix HRANDFIELD command when WITHVALUES is used. - [99f9fd83](https://github.com/phpredis/phpredis/commit/99f9fd83) + [99f9fd83](https://github.com/valkey-php/valkey-php/commit/99f9fd83) ([Michael Grunder](https://github.com/michael-grunder)) - [#2524](https://github.com/phpredis/phpredis/pull/2524) + [#2524](https://github.com/valkey-php/valkey-php/pull/2524) - Allow context array to be nullable - [50529f56](https://github.com/phpredis/phpredis/commit/50529f56) + [50529f56](https://github.com/valkey-php/valkey-php/commit/50529f56) ([michael-grunder](https://github.com/michael-grunder)) - [#2521](https://github.com/phpredis/phpredis/pull/2521) + [#2521](https://github.com/valkey-php/valkey-php/pull/2521) - Fix a macOS (M1) compiler warning. - [7de29d57](https://github.com/phpredis/phpredis/commit/7de29d57) + [7de29d57](https://github.com/valkey-php/valkey-php/commit/7de29d57) ([michael-grunder](https://github.com/michael-grunder)) -- `GETEX` documentation/updates and implentation in `RedisCluster` - [981c6931](https://github.com/phpredis/phpredis/commit/981c6931) +- `GETEX` documentation/updates and implentation in `ValkeyCluster` + [981c6931](https://github.com/valkey-php/valkey-php/commit/981c6931) ([michael-grunder](https://github.com/michael-grunder)) - [#2512](https://github.com/phpredis/phpredis/pull/2512) + [#2512](https://github.com/valkey-php/valkey-php/pull/2512) - Refactor redis_script_cmd and fix to `flush` subcommand. - [7c551424](https://github.com/phpredis/phpredis/commit/7c551424) + [7c551424](https://github.com/valkey-php/valkey-php/commit/7c551424) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Update liveness check and fix PHP 8.4 compilation error. - [c139de3a](https://github.com/phpredis/phpredis/commit/c139de3a) + [c139de3a](https://github.com/valkey-php/valkey-php/commit/c139de3a) ([michael-grunder](https://github.com/michael-grunder)) - Rework how we declare ZSTD min/max constants. - [34b5bd81](https://github.com/phpredis/phpredis/commit/34b5bd81) + [34b5bd81](https://github.com/valkey-php/valkey-php/commit/34b5bd81) ([michael-grunder](https://github.com/michael-grunder)) - [#2487](https://github.com/phpredis/phpredis/pull/2487) + [#2487](https://github.com/valkey-php/valkey-php/pull/2487) - Fix memory leak if we fail in ps_open_redis. - [0e926165](https://github.com/phpredis/phpredis/commit/0e926165) + [0e926165](https://github.com/valkey-php/valkey-php/commit/0e926165) ([michael-grunder](https://github.com/michael-grunder)) - Fix segfault and remove redundant macros - [a9e53fd1](https://github.com/phpredis/phpredis/commit/a9e53fd1) + [a9e53fd1](https://github.com/valkey-php/valkey-php/commit/a9e53fd1) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Fix PHP 8.4 includes - [a51215ce](https://github.com/phpredis/phpredis/commit/a51215ce) - [#2463](https://github.com/phpredis/phpredis/pull/2463) + [a51215ce](https://github.com/valkey-php/valkey-php/commit/a51215ce) + [#2463](https://github.com/valkey-php/valkey-php/pull/2463) ([michael-grunder](https://github.com/michael-grunder)) - Handle arbitrarily large `SCAN` cursors properly. - [2612d444](https://github.com/phpredis/phpredis/commit/2612d444) - [e52f0afa](https://github.com/phpredis/phpredis/commit/e52f0afa) - [#2454](https://github.com/phpredis/phpredis/pull/2454) - [#2458](https://github.com/phpredis/phpredis/pull/2458) + [2612d444](https://github.com/valkey-php/valkey-php/commit/2612d444) + [e52f0afa](https://github.com/valkey-php/valkey-php/commit/e52f0afa) + [#2454](https://github.com/valkey-php/valkey-php/pull/2454) + [#2458](https://github.com/valkey-php/valkey-php/pull/2458) ([michael-grunder](https://github.com/michael-grunder)) - Improve warning when we encounter an invalid EXPIRY in SET - [732e466a](https://github.com/phpredis/phpredis/commit/732e466a) - [#2448](https://github.com/phpredis/phpredis/pull/2448) + [732e466a](https://github.com/valkey-php/valkey-php/commit/732e466a) + [#2448](https://github.com/valkey-php/valkey-php/pull/2448) ([michael-grunder](https://github.com/michael-grunder)) - Fix Arginfo / zpp mismatch for DUMP command - [50e5405c](https://github.com/phpredis/phpredis/commit/50e5405c) + [50e5405c](https://github.com/valkey-php/valkey-php/commit/50e5405c) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- RedisCluster::publish returns a cluster_long_resp - [14f93339](https://github.com/phpredis/phpredis/commit/14f93339) +- ValkeyCluster::publish returns a cluster_long_resp + [14f93339](https://github.com/valkey-php/valkey-php/commit/14f93339) ([Alexandre Choura](https://github.com/PROFeNoM)) - Fix segfault when passing just false to auth. - [6dc0a0be](https://github.com/phpredis/phpredis/commit/6dc0a0be) - [#2430](https://github.com/phpredis/phpredis/pull/2430) + [6dc0a0be](https://github.com/valkey-php/valkey-php/commit/6dc0a0be) + [#2430](https://github.com/valkey-php/valkey-php/pull/2430) ([michael-grunder](https://github.com/michael-grunder)) - the VALUE argument type for hSetNx must be the same as for hSet - [df074dbe](https://github.com/phpredis/phpredis/commit/df074dbe) + [df074dbe](https://github.com/valkey-php/valkey-php/commit/df074dbe) ([Uładzimir Tsykun](https://github.com/vtsykun)) - Other fixes - [e18f6c6d](https://github.com/phpredis/phpredis/commit/e18f6c6d) - [3d7be358](https://github.com/phpredis/phpredis/commit/3d7be358) - [2b555c89](https://github.com/phpredis/phpredis/commit/2b555c89) - [fa1a283a](https://github.com/phpredis/phpredis/commit/fa1a283a) + [e18f6c6d](https://github.com/valkey-php/valkey-php/commit/e18f6c6d) + [3d7be358](https://github.com/valkey-php/valkey-php/commit/3d7be358) + [2b555c89](https://github.com/valkey-php/valkey-php/commit/2b555c89) + [fa1a283a](https://github.com/valkey-php/valkey-php/commit/fa1a283a) ([michael-grunder](https://github.com/michael-grunder)) - [37c5f8d4](https://github.com/phpredis/phpredis/commit/37c5f8d4) + [37c5f8d4](https://github.com/valkey-php/valkey-php/commit/37c5f8d4) ([Viktor Szépe](https://github.com/szepeviktor)) ### Added - Compression support for PHP sessions. - [da4ab0a7](https://github.com/phpredis/phpredis/commit/da4ab0a7) - [#2473](https://github.com/phpredis/phpredis/pull/2473) + [da4ab0a7](https://github.com/valkey-php/valkey-php/commit/da4ab0a7) + [#2473](https://github.com/valkey-php/valkey-php/pull/2473) ([bitactive](https://github.com/bitactive)) -- Support for early_refresh in Redis sessions to match cluster behavior - [b6989018](https://github.com/phpredis/phpredis/commit/b6989018) +- Support for early_refresh in Valkey sessions to match cluster behavior + [b6989018](https://github.com/valkey-php/valkey-php/commit/b6989018) ([Bitactive](https://github.com/bitactive)) - Implement WAITAOF command. - [ed7c9f6f](https://github.com/phpredis/phpredis/commit/ed7c9f6f) + [ed7c9f6f](https://github.com/valkey-php/valkey-php/commit/ed7c9f6f) ([michael-grunder](https://github.com/michael-grunder)) ### Removed - PHP 7.1, 7.2, and 7.3 CI jobs - [d68c30f8](https://github.com/phpredis/phpredis/commit/d68c30f8) - [dc39bd55](https://github.com/phpredis/phpredis/commit/dc39bd55) - [#2478](https://github.com/phpredis/phpredis/pull/2478) + [d68c30f8](https://github.com/valkey-php/valkey-php/commit/d68c30f8) + [dc39bd55](https://github.com/valkey-php/valkey-php/commit/dc39bd55) + [#2478](https://github.com/valkey-php/valkey-php/pull/2478) ([Michael Grunder](https://github.com/michael-grunder)) ### Changed - Fix the time unit of retry_interval - [3fdd52b4](https://github.com/phpredis/phpredis/commit/3fdd52b4) + [3fdd52b4](https://github.com/valkey-php/valkey-php/commit/3fdd52b4) ([woodong](https://github.com/woodongwong)) ### Documentation - Many documentation fixes. - [eeb51099](https://github.com/phpredis/phpredis/commit/eeb51099) + [eeb51099](https://github.com/valkey-php/valkey-php/commit/eeb51099) ([Michael Dwyer](https://github.com/kalifg)) - [#2523](https://github.com/phpredis/phpredis/pull/2523) + [#2523](https://github.com/valkey-php/valkey-php/pull/2523) - fix missing \ tags - [f865d5b9](https://github.com/phpredis/phpredis/commit/f865d5b9) + [f865d5b9](https://github.com/valkey-php/valkey-php/commit/f865d5b9) ([divinity76](https://github.com/divinity76)) - Mention Valkey support - [5f1eecfb](https://github.com/phpredis/phpredis/commit/5f1eecfb) + [5f1eecfb](https://github.com/valkey-php/valkey-php/commit/5f1eecfb) ([PlavorSeol](https://github.com/PlavorSeol)) - Mention KeyDB support in README.md - [37fa3592](https://github.com/phpredis/phpredis/commit/37fa3592) + [37fa3592](https://github.com/valkey-php/valkey-php/commit/37fa3592) ([Tim Starling](https://github.com/tstarling)) - Remove mention of pickle - [c7a73abb](https://github.com/phpredis/phpredis/commit/c7a73abb) + [c7a73abb](https://github.com/valkey-php/valkey-php/commit/c7a73abb) ([David Baker](https://github.com/acorncom)) - Add session.save_path examples - [8a39caeb](https://github.com/phpredis/phpredis/commit/8a39caeb) + [8a39caeb](https://github.com/valkey-php/valkey-php/commit/8a39caeb) ([Martin Vancl](https://github.com/tuxmartin)) -- Tighter return types for Redis::(keys|hKeys|hVals|hGetAll)() - [77ab62bc](https://github.com/phpredis/phpredis/commit/77ab62bc) +- Tighter return types for Valkey::(keys|hKeys|hVals|hGetAll)() + [77ab62bc](https://github.com/valkey-php/valkey-php/commit/77ab62bc) ([Benjamin Morel](https://github.com/BenMorel)) - Update stubs - [4d233977](https://github.com/phpredis/phpredis/commit/4d233977) - [ff305349](https://github.com/phpredis/phpredis/commit/ff305349) - [12966a74](https://github.com/phpredis/phpredis/commit/12966a74) - [a4a283ab](https://github.com/phpredis/phpredis/commit/a4a283ab) + [4d233977](https://github.com/valkey-php/valkey-php/commit/4d233977) + [ff305349](https://github.com/valkey-php/valkey-php/commit/ff305349) + [12966a74](https://github.com/valkey-php/valkey-php/commit/12966a74) + [a4a283ab](https://github.com/valkey-php/valkey-php/commit/a4a283ab) ([michael-grunder](https://github.com/michael-grunder)) - [8f8ff72a](https://github.com/phpredis/phpredis/commit/8f8ff72a) + [8f8ff72a](https://github.com/valkey-php/valkey-php/commit/8f8ff72a) ([Takayasu Oyama](https://github.com/taka-oyama)) - [5d293245](https://github.com/phpredis/phpredis/commit/5d293245) + [5d293245](https://github.com/valkey-php/valkey-php/commit/5d293245) - Fix config.m4 when using custom dep paths - [ece3f7be](https://github.com/phpredis/phpredis/commit/ece3f7be) + [ece3f7be](https://github.com/valkey-php/valkey-php/commit/ece3f7be) ([Michael Grunder](https://github.com/michael-grunder)) - [#2453](https://github.com/phpredis/phpredis/pull/2453) - [#2452](https://github.com/phpredis/phpredis/pull/2452) + [#2453](https://github.com/valkey-php/valkey-php/pull/2453) + [#2452](https://github.com/valkey-php/valkey-php/pull/2452) - Fix retry_internal documentation - [142c1f4a](https://github.com/phpredis/phpredis/commit/142c1f4a) + [142c1f4a](https://github.com/valkey-php/valkey-php/commit/142c1f4a) ([SplotyCode](https://github.com/SplotyCode)) - Fix anchor link - [9b5cad31](https://github.com/phpredis/phpredis/commit/9b5cad31) + [9b5cad31](https://github.com/valkey-php/valkey-php/commit/9b5cad31) ([Git'Fellow](https://github.com/solracsf)) - Fix typo in link - [bfd379f0](https://github.com/phpredis/phpredis/commit/bfd379f0) - [#2349](https://github.com/phpredis/phpredis/pull/2349) + [bfd379f0](https://github.com/valkey-php/valkey-php/commit/bfd379f0) + [#2349](https://github.com/valkey-php/valkey-php/pull/2349) ([deiga](https://github.com/deiga)) - Fix Fedora package url - [60b1ba14](https://github.com/phpredis/phpredis/commit/60b1ba14) - [717713e1](https://github.com/phpredis/phpredis/commit/717713e1) + [60b1ba14](https://github.com/valkey-php/valkey-php/commit/60b1ba14) + [717713e1](https://github.com/valkey-php/valkey-php/commit/717713e1) ([Dmitrii Kotov](https://github.com/tutunak)) -- Update Redis Sentinel documentation to reflect changes to constructor in 6.0 release - [dc05d65c](https://github.com/phpredis/phpredis/commit/dc05d65c) +- Update Valkey Sentinel documentation to reflect changes to constructor in 6.0 release + [dc05d65c](https://github.com/valkey-php/valkey-php/commit/dc05d65c) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - [#2381](https://github.com/phpredis/phpredis/pull/2381) + [#2381](https://github.com/valkey-php/valkey-php/pull/2381) ### Tests/CI - Avoid fatal error in test execution. - [57304970](https://github.com/phpredis/phpredis/commit/57304970) + [57304970](https://github.com/valkey-php/valkey-php/commit/57304970) ([Michael Grunder](https://github.com/michael-grunder)) - [#2510](https://github.com/phpredis/phpredis/pull/2510) + [#2510](https://github.com/valkey-php/valkey-php/pull/2510) - Refactor unit test framework. - [b1771def](https://github.com/phpredis/phpredis/commit/b1771def) + [b1771def](https://github.com/valkey-php/valkey-php/commit/b1771def) ([Michael Grunder](https://github.com/michael-grunder)) - [#2509](https://github.com/phpredis/phpredis/pull/2509) + [#2509](https://github.com/valkey-php/valkey-php/pull/2509) - Get unit tests working in `php-cgi`. - [b808cc60](https://github.com/phpredis/phpredis/commit/b808cc60) + [b808cc60](https://github.com/valkey-php/valkey-php/commit/b808cc60) ([michael-grunder](https://github.com/michael-grunder)) - [#2507](https://github.com/phpredis/phpredis/pull/2507) + [#2507](https://github.com/valkey-php/valkey-php/pull/2507) - Switch to `ZEND_STRL` in more places. - [7050c989](https://github.com/phpredis/phpredis/commit/7050c989) - [f8c762e7](https://github.com/phpredis/phpredis/commit/f8c762e7) + [7050c989](https://github.com/valkey-php/valkey-php/commit/7050c989) + [f8c762e7](https://github.com/valkey-php/valkey-php/commit/f8c762e7) ([Michael Grunder](https://github.com/michael-grunder)) - [#2505](https://github.com/phpredis/phpredis/pull/2505) + [#2505](https://github.com/valkey-php/valkey-php/pull/2505) - Workaround weird PHP compiler crash. - [d3b2d87b](https://github.com/phpredis/phpredis/commit/d3b2d87b) + [d3b2d87b](https://github.com/valkey-php/valkey-php/commit/d3b2d87b) ([michael-grunder](https://github.com/michael-grunder)) - Refactor tests (formatting, modernization, etc). - [dab6a62d](https://github.com/phpredis/phpredis/commit/dab6a62d) - [c6cd665b](https://github.com/phpredis/phpredis/commit/c6cd665b) - [78b70ca8](https://github.com/phpredis/phpredis/commit/78b70ca8) - [3c125b09](https://github.com/phpredis/phpredis/commit/3c125b09) - [18b0da72](https://github.com/phpredis/phpredis/commit/18b0da72) - [b88e72b1](https://github.com/phpredis/phpredis/commit/b88e72b1) - [#2492](https://github.com/phpredis/phpredis/pull/2492) - [0f94d9c1](https://github.com/phpredis/phpredis/commit/0f94d9c1) - [59965971](https://github.com/phpredis/phpredis/commit/59965971) - [3dbc2bd8](https://github.com/phpredis/phpredis/commit/3dbc2bd8) - [9b90c03b](https://github.com/phpredis/phpredis/commit/9b90c03b) - [c0d6f042](https://github.com/phpredis/phpredis/commit/c0d6f042) + [dab6a62d](https://github.com/valkey-php/valkey-php/commit/dab6a62d) + [c6cd665b](https://github.com/valkey-php/valkey-php/commit/c6cd665b) + [78b70ca8](https://github.com/valkey-php/valkey-php/commit/78b70ca8) + [3c125b09](https://github.com/valkey-php/valkey-php/commit/3c125b09) + [18b0da72](https://github.com/valkey-php/valkey-php/commit/18b0da72) + [b88e72b1](https://github.com/valkey-php/valkey-php/commit/b88e72b1) + [#2492](https://github.com/valkey-php/valkey-php/pull/2492) + [0f94d9c1](https://github.com/valkey-php/valkey-php/commit/0f94d9c1) + [59965971](https://github.com/valkey-php/valkey-php/commit/59965971) + [3dbc2bd8](https://github.com/valkey-php/valkey-php/commit/3dbc2bd8) + [9b90c03b](https://github.com/valkey-php/valkey-php/commit/9b90c03b) + [c0d6f042](https://github.com/valkey-php/valkey-php/commit/c0d6f042) ([michael-grunder](https://github.com/michael-grunder)) - Spelling fixes - [0d89e928](https://github.com/phpredis/phpredis/commit/0d89e928) + [0d89e928](https://github.com/valkey-php/valkey-php/commit/0d89e928) ([michael-grunder](https://github.com/michael-grunder)) - Added Valkey support. - [f350dc34](https://github.com/phpredis/phpredis/commit/f350dc34) + [f350dc34](https://github.com/valkey-php/valkey-php/commit/f350dc34) ([michael-grunder](https://github.com/michael-grunder)) - Add a test for session compression. - [9f3ca98c](https://github.com/phpredis/phpredis/commit/9f3ca98c) + [9f3ca98c](https://github.com/valkey-php/valkey-php/commit/9f3ca98c) ([michael-grunder](https://github.com/michael-grunder)) - [#2473](https://github.com/phpredis/phpredis/pull/2473) - [#2480](https://github.com/phpredis/phpredis/pull/2480) + [#2473](https://github.com/valkey-php/valkey-php/pull/2473) + [#2480](https://github.com/valkey-php/valkey-php/pull/2480) - Test against valkey - [a819a44b](https://github.com/phpredis/phpredis/commit/a819a44b) + [a819a44b](https://github.com/valkey-php/valkey-php/commit/a819a44b) ([michael-grunder](https://github.com/michael-grunder)) - sessionSaveHandler injection. - [9f8f80ca](https://github.com/phpredis/phpredis/commit/9f8f80ca) + [9f8f80ca](https://github.com/valkey-php/valkey-php/commit/9f8f80ca) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - KeyDB addiions - [54d62c72](https://github.com/phpredis/phpredis/commit/54d62c72) - [d9c48b78](https://github.com/phpredis/phpredis/commit/d9c48b78) - [#2466](https://github.com/phpredis/phpredis/pull/2466) + [54d62c72](https://github.com/valkey-php/valkey-php/commit/54d62c72) + [d9c48b78](https://github.com/valkey-php/valkey-php/commit/d9c48b78) + [#2466](https://github.com/valkey-php/valkey-php/pull/2466) ([michael-grunder](https://github.com/michael-grunder)) - Add PHP 8.3 to CI - [78d15140](https://github.com/phpredis/phpredis/commit/78d15140) + [78d15140](https://github.com/valkey-php/valkey-php/commit/78d15140) ([Róbert Kelčák](https://github.com/RobiNN1)) - [e051a5db](https://github.com/phpredis/phpredis/commit/e051a5db) - [#2427](https://github.com/phpredis/phpredis/pull/2427) + [e051a5db](https://github.com/valkey-php/valkey-php/commit/e051a5db) + [#2427](https://github.com/valkey-php/valkey-php/pull/2427) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Use newInstance in RedisClusterTest - [954fbab8](https://github.com/phpredis/phpredis/commit/954fbab8) +- Use newInstance in ValkeyClusterTest + [954fbab8](https://github.com/valkey-php/valkey-php/commit/954fbab8) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Use actions/checkout@v4 - [f4c2ac26](https://github.com/phpredis/phpredis/commit/f4c2ac26) + [f4c2ac26](https://github.com/valkey-php/valkey-php/commit/f4c2ac26) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Cluster nodes from ENV - [eda39958](https://github.com/phpredis/phpredis/commit/eda39958) - [0672703b](https://github.com/phpredis/phpredis/commit/0672703b) + [eda39958](https://github.com/valkey-php/valkey-php/commit/eda39958) + [0672703b](https://github.com/valkey-php/valkey-php/commit/0672703b) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Ensure we're talking to redis-server in our high ports test. - [7825efbc](https://github.com/phpredis/phpredis/commit/7825efbc) + [7825efbc](https://github.com/valkey-php/valkey-php/commit/7825efbc) ([michael-grunder](https://github.com/michael-grunder)) - Add missing option to installation example - [2bddd84f](https://github.com/phpredis/phpredis/commit/2bddd84f) + [2bddd84f](https://github.com/valkey-php/valkey-php/commit/2bddd84f) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - [#2378](https://github.com/phpredis/phpredis/pull/2378) + [#2378](https://github.com/valkey-php/valkey-php/pull/2378) - Fix typo in link - [8f6bc98f](https://github.com/phpredis/phpredis/commit/8f6bc98f) + [8f6bc98f](https://github.com/valkey-php/valkey-php/commit/8f6bc98f) ([Timo Sand](https://github.com/deiga)) - Update tests to allow users to use a custom class. - [5f6ce414](https://github.com/phpredis/phpredis/commit/5f6ce414) + [5f6ce414](https://github.com/valkey-php/valkey-php/commit/5f6ce414) ([michael-grunder](https://github.com/michael-grunder)) -## [6.0.2] - 2023-10-22 ([GitHub](https://github.com/phpredis/phpredis/releases/6.0.2), [PECL](https://pecl.php.net/package/redis/6.0.2)) +## [6.0.2] - 2023-10-22 ([GitHub](https://github.com/valkey-php/valkey-php/releases/6.0.2), [PECL](https://pecl.php.net/package/redis/6.0.2)) ### Sponsors :sparkling_heart: @@ -550,16 +550,16 @@ and PhpRedis adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Fixed - Fix deprecation error when passing null to match_type parameter. - [b835aaa3](https://github.com/phpredis/phpredis/commit/b835aaa3) + [b835aaa3](https://github.com/valkey-php/valkey-php/commit/b835aaa3) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Fix flaky test and OBJECT in a pipeline. - [a7f51f70](https://github.com/phpredis/phpredis/commit/a7f51f70) + [a7f51f70](https://github.com/valkey-php/valkey-php/commit/a7f51f70) ([Michael Grunder](https://github.com/michael-grunder)) - Find our callback by pattern with PSUBSCRIBE - [2f276dcd](https://github.com/phpredis/phpredis/commit/2f276dcd) + [2f276dcd](https://github.com/valkey-php/valkey-php/commit/2f276dcd) ([Michael Grunder](https://github.com/michael-grunder)) -## [6.0.1] - 2023-09-23 ([GitHub](https://github.com/phpredis/phpredis/releases/6.0.1), [PECL](https://pecl.php.net/package/redis/6.0.1)) +## [6.0.1] - 2023-09-23 ([GitHub](https://github.com/valkey-php/valkey-php/releases/6.0.1), [PECL](https://pecl.php.net/package/redis/6.0.1)) ### Sponsors :sparkling_heart: @@ -575,25 +575,25 @@ and PhpRedis adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - [Luis Zárate](https://github.com/jlzaratec) ### Fixed -- Fix memory leak and segfault in Redis::exec - [362e1141](https://github.com/phpredis/phpredis/commit/362e1141) +- Fix memory leak and segfault in Valkey::exec + [362e1141](https://github.com/valkey-php/valkey-php/commit/362e1141) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)), ([Markus Podar](https://github.com/mfn)) - Fix unknown expiration modifier - [264c0c7e](https://github.com/phpredis/phpredis/commit/264c0c7e), - [95bd184b](https://github.com/phpredis/phpredis/commit/95bd184b) + [264c0c7e](https://github.com/valkey-php/valkey-php/commit/264c0c7e), + [95bd184b](https://github.com/valkey-php/valkey-php/commit/95bd184b) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) ### Added - Add missing option to exampleA - [3674d663](https://github.com/phpredis/phpredis/commit/3674d663) + [3674d663](https://github.com/valkey-php/valkey-php/commit/3674d663) ([Till Krüss](https://github.com/tillkruss)) - Update sentinel documentation - [849bedb6](https://github.com/phpredis/phpredis/commit/849bedb6), - [1ad95b63](https://github.com/phpredis/phpredis/commit/1ad95b63) + [849bedb6](https://github.com/valkey-php/valkey-php/commit/849bedb6), + [1ad95b63](https://github.com/valkey-php/valkey-php/commit/1ad95b63) ([Joost OrangeJuiced](https://github.com/OrangeJuiced)) -## [6.0.0] - 2023-09-09 ([GitHub](https://github.com/phpredis/phpredis/releases/6.0.0), [PECL](https://pecl.php.net/package/redis/6.0.0)) +## [6.0.0] - 2023-09-09 ([GitHub](https://github.com/valkey-php/valkey-php/releases/6.0.0), [PECL](https://pecl.php.net/package/redis/6.0.0)) ### Sponsors :sparkling_heart: @@ -610,7 +610,7 @@ and PhpRedis adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm *There were no changes between 6.0.0 and 6.0.0RC2* -## [6.0.0RC2] - 2023-08-20 ([GitHub](https://github.com/phpredis/phpredis/releases/6.0.0RC2), [PECL](https://pecl.php.net/package/redis/6.0.0RC2)) +## [6.0.0RC2] - 2023-08-20 ([GitHub](https://github.com/valkey-php/valkey-php/releases/6.0.0RC2), [PECL](https://pecl.php.net/package/redis/6.0.0RC2)) ### Sponsors :sparkling_heart: @@ -628,16 +628,16 @@ and PhpRedis adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Fixed - Fix arginfo for arguments that default to null - [8d99b7d1](https://github.com/phpredis/phpredis/commit/8d99b7d1) + [8d99b7d1](https://github.com/valkey-php/valkey-php/commit/8d99b7d1) ([Nicolas Grekas](https://github.com/nicolas-grekas)) - Fix C99 usages - [54d9ca45](https://github.com/phpredis/phpredis/commit/54d9ca45) + [54d9ca45](https://github.com/valkey-php/valkey-php/commit/54d9ca45) ([Remi Collet](https://github.com/remicollet)) - Raise minimal supported version to 7.2 - [e10b9a85](https://github.com/phpredis/phpredis/commit/e10b9a85) + [e10b9a85](https://github.com/valkey-php/valkey-php/commit/e10b9a85) ([Remi Collet](https://github.com/remicollet)) -## [6.0.0RC1] - 2023-08-01 ([GitHub](https://github.com/phpredis/phpredis/releases/6.0.0RC1), [PECL](https://pecl.php.net/package/redis/6.0.0RC1)) +## [6.0.0RC1] - 2023-08-01 ([GitHub](https://github.com/valkey-php/valkey-php/releases/6.0.0RC1), [PECL](https://pecl.php.net/package/redis/6.0.0RC1)) ### Sponsors :sparkling_heart: @@ -655,126 +655,126 @@ and PhpRedis adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Fixed - Fix restoring keys when using compression - [82e08723](https://github.com/phpredis/phpredis/commit/82e08723) + [82e08723](https://github.com/valkey-php/valkey-php/commit/82e08723) ([Till Krüss](https://github.com/tillkruss)) -- Fix missing auth in RedisSentinel stub - [5db85561](https://github.com/phpredis/phpredis/commit/5db85561) +- Fix missing auth in ValkeySentinel stub + [5db85561](https://github.com/valkey-php/valkey-php/commit/5db85561) ([Lu Fei](https://github.com/sy-records)) -- Fix RedisSentinel pconnect check - [42cbd88a](https://github.com/phpredis/phpredis/commit/42cbd88a) +- Fix ValkeySentinel pconnect check + [42cbd88a](https://github.com/valkey-php/valkey-php/commit/42cbd88a) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Fix NULL-pointer dereferences and handle possible UB - [36457555](https://github.com/phpredis/phpredis/commit/36457555) + [36457555](https://github.com/valkey-php/valkey-php/commit/36457555) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Fix security alerts - [ee210f86](https://github.com/phpredis/phpredis/commit/ee210f86), - [fb6a297c](https://github.com/phpredis/phpredis/commit/fb6a297c) + [ee210f86](https://github.com/valkey-php/valkey-php/commit/ee210f86), + [fb6a297c](https://github.com/valkey-php/valkey-php/commit/fb6a297c) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)), ([Michael Grunder](https://github.com/michael-grunder)) - Fix segfault - [55bf0202](https://github.com/phpredis/phpredis/commit/55bf0202) + [55bf0202](https://github.com/valkey-php/valkey-php/commit/55bf0202) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Fix default host length - [c40f9d6c](https://github.com/phpredis/phpredis/commit/c40f9d6c) + [c40f9d6c](https://github.com/valkey-php/valkey-php/commit/c40f9d6c) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Fix redis session standalone stream ssl context - [ed10f365](https://github.com/phpredis/phpredis/commit/ed10f365), - [d1bc6727](https://github.com/phpredis/phpredis/commit/d1bc6727), - [2ff11df5](https://github.com/phpredis/phpredis/commit/2ff11df5) + [ed10f365](https://github.com/valkey-php/valkey-php/commit/ed10f365), + [d1bc6727](https://github.com/valkey-php/valkey-php/commit/d1bc6727), + [2ff11df5](https://github.com/valkey-php/valkey-php/commit/2ff11df5) ([patricio.dorantes](https://github.com/patricio.dorantes)) - Fix segfault with session+tls - [a471c87a](https://github.com/phpredis/phpredis/commit/a471c87a) + [a471c87a](https://github.com/valkey-php/valkey-php/commit/a471c87a) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Fix non standards conforming prototypes. - [b3ce0486](https://github.com/phpredis/phpredis/commit/b3ce0486) + [b3ce0486](https://github.com/valkey-php/valkey-php/commit/b3ce0486) ([Michael Grunder](https://github.com/michael-grunder)) - Avoid registering the same replicas multiple times - [f2bfd723](https://github.com/phpredis/phpredis/commit/f2bfd723) + [f2bfd723](https://github.com/valkey-php/valkey-php/commit/f2bfd723) ([Marius Adam](https://github.com/mariusadam)) - Better unix:// or file:// detection. - [d05d301b](https://github.com/phpredis/phpredis/commit/d05d301b) + [d05d301b](https://github.com/valkey-php/valkey-php/commit/d05d301b) ([Michael Grunder](https://github.com/michael-grunder)) - Future proof our igbinary header check - [69355faa](https://github.com/phpredis/phpredis/commit/69355faa) + [69355faa](https://github.com/valkey-php/valkey-php/commit/69355faa) ([Michael Grunder](https://github.com/michael-grunder)) - Fix BITOP cross-slot bug - [af13f951](https://github.com/phpredis/phpredis/commit/af13f951) + [af13f951](https://github.com/valkey-php/valkey-php/commit/af13f951) ([Michael Grunder](https://github.com/michael-grunder)) - SENTINEL RESET returns a long. - [0243dd9d](https://github.com/phpredis/phpredis/commit/0243dd9d) + [0243dd9d](https://github.com/valkey-php/valkey-php/commit/0243dd9d) ([Michael Grunder](https://github.com/michael-grunder)) - Fix redis_sock_read_multibulk_multi_reply_loop logic - [d9cb5946](https://github.com/phpredis/phpredis/commit/d9cb5946), - [5a643b62](https://github.com/phpredis/phpredis/commit/5a643b62) + [d9cb5946](https://github.com/valkey-php/valkey-php/commit/d9cb5946), + [5a643b62](https://github.com/valkey-php/valkey-php/commit/5a643b62) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Fix RPOP to unserialize/decompress data. - [02c91d59](https://github.com/phpredis/phpredis/commit/02c91d59) + [02c91d59](https://github.com/valkey-php/valkey-php/commit/02c91d59) ([Michael Grunder](https://github.com/michael-grunder)) - Fix testObject for redis 7.2 - [fea19b52](https://github.com/phpredis/phpredis/commit/fea19b52), - [dcb95a3f](https://github.com/phpredis/phpredis/commit/dcb95a3f) + [fea19b52](https://github.com/valkey-php/valkey-php/commit/fea19b52), + [dcb95a3f](https://github.com/valkey-php/valkey-php/commit/dcb95a3f) ([Remi Collet](https://github.com/remicollet)) - Fix bug: the pipeline mode socket return an unexpected result after reconnecting - [a3327d9d](https://github.com/phpredis/phpredis/commit/a3327d9d) + [a3327d9d](https://github.com/valkey-php/valkey-php/commit/a3327d9d) ([thomaston](https://github.com/omigafu)) - Fix stub files - [9aa5f387](https://github.com/phpredis/phpredis/commit/9aa5f387), - [74cf49f5](https://github.com/phpredis/phpredis/commit/74cf49f5), - [8b1eafe8](https://github.com/phpredis/phpredis/commit/8b1eafe8), - [e392dd88](https://github.com/phpredis/phpredis/commit/e392dd88), - [b5ea5fd7](https://github.com/phpredis/phpredis/commit/b5ea5fd7), - [71758b09](https://github.com/phpredis/phpredis/commit/71758b09), - [2a6dee5d](https://github.com/phpredis/phpredis/commit/2a6dee5d) + [9aa5f387](https://github.com/valkey-php/valkey-php/commit/9aa5f387), + [74cf49f5](https://github.com/valkey-php/valkey-php/commit/74cf49f5), + [8b1eafe8](https://github.com/valkey-php/valkey-php/commit/8b1eafe8), + [e392dd88](https://github.com/valkey-php/valkey-php/commit/e392dd88), + [b5ea5fd7](https://github.com/valkey-php/valkey-php/commit/b5ea5fd7), + [71758b09](https://github.com/valkey-php/valkey-php/commit/71758b09), + [2a6dee5d](https://github.com/valkey-php/valkey-php/commit/2a6dee5d) ([Nicolas Grekas](https://github.com/nicolas-grekas)), ([Michael Grunder](https://github.com/michael-grunder)) - Update documentation - [b64d93e1](https://github.com/phpredis/phpredis/commit/b64d93e1), - [703d71b5](https://github.com/phpredis/phpredis/commit/703d71b5), - [eba1c6d2](https://github.com/phpredis/phpredis/commit/eba1c6d2), - [0f502c9e](https://github.com/phpredis/phpredis/commit/0f502c9e), - [130b5d0b](https://github.com/phpredis/phpredis/commit/130b5d0b), - [21c3ef94](https://github.com/phpredis/phpredis/commit/21c3ef94), - [b7bf22d4](https://github.com/phpredis/phpredis/commit/b7bf22d4), - [50151e7a](https://github.com/phpredis/phpredis/commit/50151e7a), - [b9950727](https://github.com/phpredis/phpredis/commit/b9950727), - [ab4ce4ab](https://github.com/phpredis/phpredis/commit/ab4ce4ab), - [8d80ca5b](https://github.com/phpredis/phpredis/commit/8d80ca5b), - [c4de8667](https://github.com/phpredis/phpredis/commit/c4de8667), - [6982941b](https://github.com/phpredis/phpredis/commit/6982941b), - [375d093d](https://github.com/phpredis/phpredis/commit/375d093d), - [43da8dd9](https://github.com/phpredis/phpredis/commit/43da8dd9), - [71344612](https://github.com/phpredis/phpredis/commit/71344612), - [b9de0b97](https://github.com/phpredis/phpredis/commit/b9de0b97), - [2d8a8a44](https://github.com/phpredis/phpredis/commit/2d8a8a44), - [a2b0c86f](https://github.com/phpredis/phpredis/commit/a2b0c86f), - [e0b24be1](https://github.com/phpredis/phpredis/commit/e0b24be1), - [e609fbe8](https://github.com/phpredis/phpredis/commit/e609fbe8), - [c4aef956](https://github.com/phpredis/phpredis/commit/c4aef956), - [df50b2ad](https://github.com/phpredis/phpredis/commit/df50b2ad), - [cc2383f0](https://github.com/phpredis/phpredis/commit/cc2383f0), - [0dd2836f](https://github.com/phpredis/phpredis/commit/0dd2836f), - [7d5db510](https://github.com/phpredis/phpredis/commit/7d5db510), - [99340889](https://github.com/phpredis/phpredis/commit/99340889), - [70a55f3e](https://github.com/phpredis/phpredis/commit/70a55f3e), - [b04684d4](https://github.com/phpredis/phpredis/commit/b04684d4), - [980ea6b1](https://github.com/phpredis/phpredis/commit/980ea6b1), - [bb06ffa3](https://github.com/phpredis/phpredis/commit/bb06ffa3), - [b8679d7a](https://github.com/phpredis/phpredis/commit/b8679d7a), - [854f3aa4](https://github.com/phpredis/phpredis/commit/854f3aa4), - [a5c47901](https://github.com/phpredis/phpredis/commit/a5c47901), - [cf63e96e](https://github.com/phpredis/phpredis/commit/cf63e96e), - [f05ba819](https://github.com/phpredis/phpredis/commit/f05ba819), - [17db2328](https://github.com/phpredis/phpredis/commit/17db2328), - [450904f7](https://github.com/phpredis/phpredis/commit/450904f7), - [114f4d60](https://github.com/phpredis/phpredis/commit/114f4d60), - [142bddf0](https://github.com/phpredis/phpredis/commit/142bddf0), - [87fa36d6](https://github.com/phpredis/phpredis/commit/87fa36d6), - [531177d4](https://github.com/phpredis/phpredis/commit/531177d4), - [ecf65144](https://github.com/phpredis/phpredis/commit/ecf65144), - [53d142d9](https://github.com/phpredis/phpredis/commit/53d142d9), - [c14a9e3a](https://github.com/phpredis/phpredis/commit/c14a9e3a), - [72f8eb25](https://github.com/phpredis/phpredis/commit/72f8eb25), - [872b6931](https://github.com/phpredis/phpredis/commit/872b6931) + [b64d93e1](https://github.com/valkey-php/valkey-php/commit/b64d93e1), + [703d71b5](https://github.com/valkey-php/valkey-php/commit/703d71b5), + [eba1c6d2](https://github.com/valkey-php/valkey-php/commit/eba1c6d2), + [0f502c9e](https://github.com/valkey-php/valkey-php/commit/0f502c9e), + [130b5d0b](https://github.com/valkey-php/valkey-php/commit/130b5d0b), + [21c3ef94](https://github.com/valkey-php/valkey-php/commit/21c3ef94), + [b7bf22d4](https://github.com/valkey-php/valkey-php/commit/b7bf22d4), + [50151e7a](https://github.com/valkey-php/valkey-php/commit/50151e7a), + [b9950727](https://github.com/valkey-php/valkey-php/commit/b9950727), + [ab4ce4ab](https://github.com/valkey-php/valkey-php/commit/ab4ce4ab), + [8d80ca5b](https://github.com/valkey-php/valkey-php/commit/8d80ca5b), + [c4de8667](https://github.com/valkey-php/valkey-php/commit/c4de8667), + [6982941b](https://github.com/valkey-php/valkey-php/commit/6982941b), + [375d093d](https://github.com/valkey-php/valkey-php/commit/375d093d), + [43da8dd9](https://github.com/valkey-php/valkey-php/commit/43da8dd9), + [71344612](https://github.com/valkey-php/valkey-php/commit/71344612), + [b9de0b97](https://github.com/valkey-php/valkey-php/commit/b9de0b97), + [2d8a8a44](https://github.com/valkey-php/valkey-php/commit/2d8a8a44), + [a2b0c86f](https://github.com/valkey-php/valkey-php/commit/a2b0c86f), + [e0b24be1](https://github.com/valkey-php/valkey-php/commit/e0b24be1), + [e609fbe8](https://github.com/valkey-php/valkey-php/commit/e609fbe8), + [c4aef956](https://github.com/valkey-php/valkey-php/commit/c4aef956), + [df50b2ad](https://github.com/valkey-php/valkey-php/commit/df50b2ad), + [cc2383f0](https://github.com/valkey-php/valkey-php/commit/cc2383f0), + [0dd2836f](https://github.com/valkey-php/valkey-php/commit/0dd2836f), + [7d5db510](https://github.com/valkey-php/valkey-php/commit/7d5db510), + [99340889](https://github.com/valkey-php/valkey-php/commit/99340889), + [70a55f3e](https://github.com/valkey-php/valkey-php/commit/70a55f3e), + [b04684d4](https://github.com/valkey-php/valkey-php/commit/b04684d4), + [980ea6b1](https://github.com/valkey-php/valkey-php/commit/980ea6b1), + [bb06ffa3](https://github.com/valkey-php/valkey-php/commit/bb06ffa3), + [b8679d7a](https://github.com/valkey-php/valkey-php/commit/b8679d7a), + [854f3aa4](https://github.com/valkey-php/valkey-php/commit/854f3aa4), + [a5c47901](https://github.com/valkey-php/valkey-php/commit/a5c47901), + [cf63e96e](https://github.com/valkey-php/valkey-php/commit/cf63e96e), + [f05ba819](https://github.com/valkey-php/valkey-php/commit/f05ba819), + [17db2328](https://github.com/valkey-php/valkey-php/commit/17db2328), + [450904f7](https://github.com/valkey-php/valkey-php/commit/450904f7), + [114f4d60](https://github.com/valkey-php/valkey-php/commit/114f4d60), + [142bddf0](https://github.com/valkey-php/valkey-php/commit/142bddf0), + [87fa36d6](https://github.com/valkey-php/valkey-php/commit/87fa36d6), + [531177d4](https://github.com/valkey-php/valkey-php/commit/531177d4), + [ecf65144](https://github.com/valkey-php/valkey-php/commit/ecf65144), + [53d142d9](https://github.com/valkey-php/valkey-php/commit/53d142d9), + [c14a9e3a](https://github.com/valkey-php/valkey-php/commit/c14a9e3a), + [72f8eb25](https://github.com/valkey-php/valkey-php/commit/72f8eb25), + [872b6931](https://github.com/valkey-php/valkey-php/commit/872b6931) ([Karina Kwiatek](https://github.com/raccube)), ([Nicolas Grekas](https://github.com/nicolas-grekas)), ([Muhammad Dyas Yaskur](https://github.com/dyaskur)), @@ -789,332 +789,332 @@ and PhpRedis adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Changed - Allow to pass null as iterator - [14d121bb](https://github.com/phpredis/phpredis/commit/14d121bb) + [14d121bb](https://github.com/valkey-php/valkey-php/commit/14d121bb) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Add NOMKSTREAM option to XADD command. - [f9436e25](https://github.com/phpredis/phpredis/commit/f9436e25) + [f9436e25](https://github.com/valkey-php/valkey-php/commit/f9436e25) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Don't allow reconnect on read response - [5a269ab6](https://github.com/phpredis/phpredis/commit/5a269ab6) + [5a269ab6](https://github.com/valkey-php/valkey-php/commit/5a269ab6) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Reset multi/pipline transaction on pconnect close - [0879770a](https://github.com/phpredis/phpredis/commit/0879770a) + [0879770a](https://github.com/valkey-php/valkey-php/commit/0879770a) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Use read_mbulk_header helper where possible - [ca8b4c93](https://github.com/phpredis/phpredis/commit/ca8b4c93) + [ca8b4c93](https://github.com/valkey-php/valkey-php/commit/ca8b4c93) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Allow to pass null as auth argument - [41517753](https://github.com/phpredis/phpredis/commit/41517753) + [41517753](https://github.com/valkey-php/valkey-php/commit/41517753) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Refactor redis_parse_client_list_response - [68136a29](https://github.com/phpredis/phpredis/commit/68136a29), - [aaa4c91a](https://github.com/phpredis/phpredis/commit/aaa4c91a), - [1fb2935b](https://github.com/phpredis/phpredis/commit/1fb2935b), - [cf2c052c](https://github.com/phpredis/phpredis/commit/cf2c052c) + [68136a29](https://github.com/valkey-php/valkey-php/commit/68136a29), + [aaa4c91a](https://github.com/valkey-php/valkey-php/commit/aaa4c91a), + [1fb2935b](https://github.com/valkey-php/valkey-php/commit/1fb2935b), + [cf2c052c](https://github.com/valkey-php/valkey-php/commit/cf2c052c) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Refactor subscribe/unsubscribe - [3c9e159c](https://github.com/phpredis/phpredis/commit/3c9e159c) + [3c9e159c](https://github.com/valkey-php/valkey-php/commit/3c9e159c) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Change PHPREDIS_CTX_PTR type - [de3635da](https://github.com/phpredis/phpredis/commit/de3635da) +- Change PHPVALKEY_CTX_PTR type + [de3635da](https://github.com/valkey-php/valkey-php/commit/de3635da) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Refactor redis_parse_info_response - [982bd13b](https://github.com/phpredis/phpredis/commit/982bd13b) + [982bd13b](https://github.com/valkey-php/valkey-php/commit/982bd13b) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Allow IPv6 address within square brackets - [c28ad7bb](https://github.com/phpredis/phpredis/commit/c28ad7bb) + [c28ad7bb](https://github.com/valkey-php/valkey-php/commit/c28ad7bb) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Allow multiple field-value pairs for hmset command. - [e858e8e3](https://github.com/phpredis/phpredis/commit/e858e8e3) + [e858e8e3](https://github.com/valkey-php/valkey-php/commit/e858e8e3) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Refactor MINIT and use @generate-class-entries in stub files - [3675f442](https://github.com/phpredis/phpredis/commit/3675f442) + [3675f442](https://github.com/valkey-php/valkey-php/commit/3675f442) ([Remi Collet](https://github.com/remicollet)) - Use spl_ce_RuntimeException - [3cd5ac1e](https://github.com/phpredis/phpredis/commit/3cd5ac1e), - [a7e5ea64](https://github.com/phpredis/phpredis/commit/a7e5ea64) + [3cd5ac1e](https://github.com/valkey-php/valkey-php/commit/3cd5ac1e), + [a7e5ea64](https://github.com/valkey-php/valkey-php/commit/a7e5ea64) ([Remi Collet](https://github.com/remicollet)) - Regenerate arginfo using 8.2.0 - [a38e08da](https://github.com/phpredis/phpredis/commit/a38e08da) + [a38e08da](https://github.com/valkey-php/valkey-php/commit/a38e08da) ([Remi Collet](https://github.com/remicollet)) - Refactor client command - [a8d10291](https://github.com/phpredis/phpredis/commit/a8d10291) + [a8d10291](https://github.com/valkey-php/valkey-php/commit/a8d10291) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Pull COUNT/ANY parsing into a helper function - [d67b2020](https://github.com/phpredis/phpredis/commit/d67b2020) + [d67b2020](https://github.com/valkey-php/valkey-php/commit/d67b2020) ([Michael Grunder](https://github.com/michael-grunder)) - Return false or NULL on empty lpos response - [39a01ac7](https://github.com/phpredis/phpredis/commit/39a01ac7) + [39a01ac7](https://github.com/valkey-php/valkey-php/commit/39a01ac7) ([Michael Grunder](https://github.com/michael-grunder)) - BLPOP with a float timeout - [a98605f2](https://github.com/phpredis/phpredis/commit/a98605f2), - [dc9af529](https://github.com/phpredis/phpredis/commit/dc9af529) + [a98605f2](https://github.com/valkey-php/valkey-php/commit/a98605f2), + [dc9af529](https://github.com/valkey-php/valkey-php/commit/dc9af529) ([Michael Grunder](https://github.com/michael-grunder)) - Make sure we set an error for key based scans - [98fda1b8](https://github.com/phpredis/phpredis/commit/98fda1b8) + [98fda1b8](https://github.com/valkey-php/valkey-php/commit/98fda1b8) ([Michael Grunder](https://github.com/michael-grunder)) - Add back a default switch case for setoption handler - [87464932](https://github.com/phpredis/phpredis/commit/87464932) + [87464932](https://github.com/valkey-php/valkey-php/commit/87464932) ([Michael Grunder](https://github.com/michael-grunder)) - Update stubs so the tests pass in strict mode - [bebd398c](https://github.com/phpredis/phpredis/commit/bebd398c) + [bebd398c](https://github.com/valkey-php/valkey-php/commit/bebd398c) ([Michael Grunder](https://github.com/michael-grunder)) - Move where we generate our salt - [d2044c9f](https://github.com/phpredis/phpredis/commit/d2044c9f) + [d2044c9f](https://github.com/valkey-php/valkey-php/commit/d2044c9f) ([Michael Grunder](https://github.com/michael-grunder)) - Refactor XINFO handler - [3b0d8b77](https://github.com/phpredis/phpredis/commit/3b0d8b77) + [3b0d8b77](https://github.com/valkey-php/valkey-php/commit/3b0d8b77) ([Michael Grunder](https://github.com/michael-grunder)) - Refactor and fix XPENDING handler - [457953f4](https://github.com/phpredis/phpredis/commit/457953f4) + [457953f4](https://github.com/valkey-php/valkey-php/commit/457953f4) ([Michael Grunder](https://github.com/michael-grunder)) - Refactor FLUSHDB and update docs. - [54a084e5](https://github.com/phpredis/phpredis/commit/54a084e5) + [54a084e5](https://github.com/valkey-php/valkey-php/commit/54a084e5) ([Michael Grunder](https://github.com/michael-grunder)) - Add missing directed node command to docs and refactor stubs. - [5ac92d25](https://github.com/phpredis/phpredis/commit/5ac92d25) + [5ac92d25](https://github.com/valkey-php/valkey-php/commit/5ac92d25) ([Michael Grunder](https://github.com/michael-grunder)) - Refactor BITPOS and implement BIT/BYTE option. - [4d8afd38](https://github.com/phpredis/phpredis/commit/4d8afd38) + [4d8afd38](https://github.com/valkey-php/valkey-php/commit/4d8afd38) ([Michael Grunder](https://github.com/michael-grunder)) - INFO with multiple sections - [44d03ca0](https://github.com/phpredis/phpredis/commit/44d03ca0) + [44d03ca0](https://github.com/valkey-php/valkey-php/commit/44d03ca0) ([Michael Grunder](https://github.com/michael-grunder)) - Refactor SLOWLOG command - [d87f1428](https://github.com/phpredis/phpredis/commit/d87f1428) + [d87f1428](https://github.com/valkey-php/valkey-php/commit/d87f1428) ([Michael Grunder](https://github.com/michael-grunder)) - Refactor SORT and add SORT_RO command - [8c7c5a3a](https://github.com/phpredis/phpredis/commit/8c7c5a3a) + [8c7c5a3a](https://github.com/valkey-php/valkey-php/commit/8c7c5a3a) ([Michael Grunder](https://github.com/michael-grunder)) - Use ZEND_STRL in redis_commands.c - [78de25a3](https://github.com/phpredis/phpredis/commit/78de25a3) + [78de25a3](https://github.com/valkey-php/valkey-php/commit/78de25a3) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Refactor PubSub command - [2a0d1c1e](https://github.com/phpredis/phpredis/commit/2a0d1c1e) + [2a0d1c1e](https://github.com/valkey-php/valkey-php/commit/2a0d1c1e) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Refactor SLAVEOF handler - [f2cef8be](https://github.com/phpredis/phpredis/commit/f2cef8be) + [f2cef8be](https://github.com/valkey-php/valkey-php/commit/f2cef8be) ([Michael Grunder](https://github.com/michael-grunder)) - Refactor ACL command - [504810a5](https://github.com/phpredis/phpredis/commit/504810a5) + [504810a5](https://github.com/valkey-php/valkey-php/commit/504810a5) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Use fast_zpp API - [376d4d27](https://github.com/phpredis/phpredis/commit/376d4d27) + [376d4d27](https://github.com/valkey-php/valkey-php/commit/376d4d27) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Fix XAUTOCLAIM response handler - [0b7bd83f](https://github.com/phpredis/phpredis/commit/0b7bd83f) + [0b7bd83f](https://github.com/valkey-php/valkey-php/commit/0b7bd83f) ([Michael Grunder](https://github.com/michael-grunder)) - Refactor `command` command - [ff863f3f](https://github.com/phpredis/phpredis/commit/ff863f3f) + [ff863f3f](https://github.com/valkey-php/valkey-php/commit/ff863f3f) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Refactor rawCommand and WAIT - [79c9d224](https://github.com/phpredis/phpredis/commit/79c9d224) + [79c9d224](https://github.com/valkey-php/valkey-php/commit/79c9d224) ([Michael Grunder](https://github.com/michael-grunder)) - Refactor SELECT command - [86f15cca](https://github.com/phpredis/phpredis/commit/86f15cca) + [86f15cca](https://github.com/valkey-php/valkey-php/commit/86f15cca) ([Michael Grunder](https://github.com/michael-grunder)) - Refactor SRANDMEMBER command. - [f62363c2](https://github.com/phpredis/phpredis/commit/f62363c2) + [f62363c2](https://github.com/valkey-php/valkey-php/commit/f62363c2) ([Michael Grunder](https://github.com/michael-grunder)) - Refactor OBJECT command. - [acb5db76](https://github.com/phpredis/phpredis/commit/acb5db76) + [acb5db76](https://github.com/valkey-php/valkey-php/commit/acb5db76) ([Michael Grunder](https://github.com/michael-grunder)) - Refactor gen_varkey_cmd - [3efa59cb](https://github.com/phpredis/phpredis/commit/3efa59cb) + [3efa59cb](https://github.com/valkey-php/valkey-php/commit/3efa59cb) ([Michael Grunder](https://github.com/michael-grunder)) - Refactor MGET command. - [8cb6dd17](https://github.com/phpredis/phpredis/commit/8cb6dd17) + [8cb6dd17](https://github.com/valkey-php/valkey-php/commit/8cb6dd17) ([Michael Grunder](https://github.com/michael-grunder)) - Refactor INFO and SCRIPT commands. - [3574ef08](https://github.com/phpredis/phpredis/commit/3574ef08) + [3574ef08](https://github.com/valkey-php/valkey-php/commit/3574ef08) ([Michael Grunder](https://github.com/michael-grunder)) - Refactor MSET and MSETNX commands. - [6d104481](https://github.com/phpredis/phpredis/commit/6d104481) + [6d104481](https://github.com/valkey-php/valkey-php/commit/6d104481) ([Michael Grunder](https://github.com/michael-grunder)) - Refactor HMSET command. - [90eb0470](https://github.com/phpredis/phpredis/commit/90eb0470) + [90eb0470](https://github.com/valkey-php/valkey-php/commit/90eb0470) ([Michael Grunder](https://github.com/michael-grunder)) - Refactor PFCOUNT command. - [19fd7e0c](https://github.com/phpredis/phpredis/commit/19fd7e0c) + [19fd7e0c](https://github.com/valkey-php/valkey-php/commit/19fd7e0c) ([Michael Grunder](https://github.com/michael-grunder)) - Refactor SMOVE command. - [204a02c5](https://github.com/phpredis/phpredis/commit/204a02c5) + [204a02c5](https://github.com/valkey-php/valkey-php/commit/204a02c5) ([Michael Grunder](https://github.com/michael-grunder)) - Rework ZRANGE argument handling. - [aa0938a4](https://github.com/phpredis/phpredis/commit/aa0938a4) + [aa0938a4](https://github.com/valkey-php/valkey-php/commit/aa0938a4) ([Michael Grunder](https://github.com/michael-grunder)) - Refactor a couple more command methods. - [5b560ccf](https://github.com/phpredis/phpredis/commit/5b560ccf), - [c8224b93](https://github.com/phpredis/phpredis/commit/c8224b93), - [40e1b1bf](https://github.com/phpredis/phpredis/commit/40e1b1bf), - [ccd419a4](https://github.com/phpredis/phpredis/commit/ccd419a4) + [5b560ccf](https://github.com/valkey-php/valkey-php/commit/5b560ccf), + [c8224b93](https://github.com/valkey-php/valkey-php/commit/c8224b93), + [40e1b1bf](https://github.com/valkey-php/valkey-php/commit/40e1b1bf), + [ccd419a4](https://github.com/valkey-php/valkey-php/commit/ccd419a4) ([Michael Grunder](https://github.com/michael-grunder)) - Refactor HMGET command - [bb66a547](https://github.com/phpredis/phpredis/commit/bb66a547) + [bb66a547](https://github.com/valkey-php/valkey-php/commit/bb66a547) ([Michael Grunder](https://github.com/michael-grunder)) - Refactor CLIENT command - [77c4f7a3](https://github.com/phpredis/phpredis/commit/77c4f7a3) + [77c4f7a3](https://github.com/valkey-php/valkey-php/commit/77c4f7a3) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Refactor redis_long_response - [f14a80db](https://github.com/phpredis/phpredis/commit/f14a80db) + [f14a80db](https://github.com/valkey-php/valkey-php/commit/f14a80db) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Synchronize Redis and RedisSentinel constructors - [ebb2386e](https://github.com/phpredis/phpredis/commit/ebb2386e) +- Synchronize Valkey and ValkeySentinel constructors + [ebb2386e](https://github.com/valkey-php/valkey-php/commit/ebb2386e) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Use redis_sock_connect on connect - [f6c8b9c6](https://github.com/phpredis/phpredis/commit/f6c8b9c6) + [f6c8b9c6](https://github.com/valkey-php/valkey-php/commit/f6c8b9c6) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Auto-select db in redis_sock_server_open - [6930a81c](https://github.com/phpredis/phpredis/commit/6930a81c) + [6930a81c](https://github.com/valkey-php/valkey-php/commit/6930a81c) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Use on-stack allocated valiables - [7a055cad](https://github.com/phpredis/phpredis/commit/7a055cad) + [7a055cad](https://github.com/valkey-php/valkey-php/commit/7a055cad) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) ### Added - Add XAUTOCLAIM command - [01f3342c](https://github.com/phpredis/phpredis/commit/01f3342c) + [01f3342c](https://github.com/valkey-php/valkey-php/commit/01f3342c) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Add SYNC arg to FLUSHALL and FLUSHDB, and ASYNC/SYNC arg to SCRIPT FLUSH - [750b6cf3](https://github.com/phpredis/phpredis/commit/750b6cf3) + [750b6cf3](https://github.com/valkey-php/valkey-php/commit/750b6cf3) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Add reset command - [947a2d38](https://github.com/phpredis/phpredis/commit/947a2d38) + [947a2d38](https://github.com/valkey-php/valkey-php/commit/947a2d38) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Add hRandField command - [fe397371](https://github.com/phpredis/phpredis/commit/fe397371) + [fe397371](https://github.com/valkey-php/valkey-php/commit/fe397371) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Add PXAT/EXAT arguments to SET command. - [0a160685](https://github.com/phpredis/phpredis/commit/0a160685) + [0a160685](https://github.com/valkey-php/valkey-php/commit/0a160685) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Add GETEX, GETDEL commands. - [11861d95](https://github.com/phpredis/phpredis/commit/11861d95) + [11861d95](https://github.com/valkey-php/valkey-php/commit/11861d95) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Add FAILOVER command. - [4b767be7](https://github.com/phpredis/phpredis/commit/4b767be7) + [4b767be7](https://github.com/valkey-php/valkey-php/commit/4b767be7) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Backoff settings in constructor - [e6b3fe54](https://github.com/phpredis/phpredis/commit/e6b3fe54) + [e6b3fe54](https://github.com/valkey-php/valkey-php/commit/e6b3fe54) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Add the COUNT argument to LPOP and RPOP - [df97cc35](https://github.com/phpredis/phpredis/commit/df97cc35) + [df97cc35](https://github.com/valkey-php/valkey-php/commit/df97cc35) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Unsubscribe from all channels - [0f1ca0cc](https://github.com/phpredis/phpredis/commit/0f1ca0cc) + [0f1ca0cc](https://github.com/valkey-php/valkey-php/commit/0f1ca0cc) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Add lPos command. - [687a5c78](https://github.com/phpredis/phpredis/commit/687a5c78) + [687a5c78](https://github.com/valkey-php/valkey-php/commit/687a5c78) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Add the ANY argument to GEOSEARCH and GEORADIUS - [bf6f31e3](https://github.com/phpredis/phpredis/commit/bf6f31e3) + [bf6f31e3](https://github.com/valkey-php/valkey-php/commit/bf6f31e3) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Add 'BIT'/'BYTE' modifier to BITCOUNT + tests - [a3d2f131](https://github.com/phpredis/phpredis/commit/a3d2f131) + [a3d2f131](https://github.com/valkey-php/valkey-php/commit/a3d2f131) ([Michael Grunder](https://github.com/michael-grunder)) - Add missing configureoption entries in package.xml - [59053f10](https://github.com/phpredis/phpredis/commit/59053f10) + [59053f10](https://github.com/valkey-php/valkey-php/commit/59053f10) ([Michele Locati](https://github.com/mlocati)) - Implement CONFIG RESETSTAT - [239678a0](https://github.com/phpredis/phpredis/commit/239678a0) + [239678a0](https://github.com/valkey-php/valkey-php/commit/239678a0) ([Michael Grunder](https://github.com/michael-grunder)) - SINTERCARD and ZINTERCARD commands - [64300508](https://github.com/phpredis/phpredis/commit/64300508) + [64300508](https://github.com/valkey-php/valkey-php/commit/64300508) ([Michael Grunder](https://github.com/michael-grunder)) - LCS command - [c0e839f6](https://github.com/phpredis/phpredis/commit/c0e839f6) + [c0e839f6](https://github.com/valkey-php/valkey-php/commit/c0e839f6) ([Michael Grunder](https://github.com/michael-grunder)) - EXPIRETIME and PEXPIRETIME - [f5b2a09b](https://github.com/phpredis/phpredis/commit/f5b2a09b) + [f5b2a09b](https://github.com/valkey-php/valkey-php/commit/f5b2a09b) ([Michael Grunder](https://github.com/michael-grunder)) - [B]LMPOP and [B]ZMPOP commands - [6ea978eb](https://github.com/phpredis/phpredis/commit/6ea978eb) + [6ea978eb](https://github.com/valkey-php/valkey-php/commit/6ea978eb) ([Michael Grunder](https://github.com/michael-grunder)) - Implement new RESTORE options - [9a3fe401](https://github.com/phpredis/phpredis/commit/9a3fe401) + [9a3fe401](https://github.com/valkey-php/valkey-php/commit/9a3fe401) ([Michael Grunder](https://github.com/michael-grunder)) -- Add new Redis 6.2.0 XTRIM options - [6b34d17f](https://github.com/phpredis/phpredis/commit/6b34d17f) +- Add new Valkey 6.2.0 XTRIM options + [6b34d17f](https://github.com/valkey-php/valkey-php/commit/6b34d17f) ([Michael Grunder](https://github.com/michael-grunder)) - Implement AUTH/AUTH2 arguments for MIGRATE - [114d79d1](https://github.com/phpredis/phpredis/commit/114d79d1) + [114d79d1](https://github.com/valkey-php/valkey-php/commit/114d79d1) ([Michael Grunder](https://github.com/michael-grunder)) - Implement CONFIG REWRITE - [525958ea](https://github.com/phpredis/phpredis/commit/525958ea) + [525958ea](https://github.com/valkey-php/valkey-php/commit/525958ea) ([Michael Grunder](https://github.com/michael-grunder)) -- Implement Redis 7.0.0 [P]EXPIRE[AT] options - [872ae107](https://github.com/phpredis/phpredis/commit/872ae107) +- Implement Valkey 7.0.0 [P]EXPIRE[AT] options + [872ae107](https://github.com/valkey-php/valkey-php/commit/872ae107) ([Michael Grunder](https://github.com/michael-grunder)) - Variadic CONFIG GET/SET - [36ef4bd8](https://github.com/phpredis/phpredis/commit/36ef4bd8), - [a176f586](https://github.com/phpredis/phpredis/commit/a176f586) + [36ef4bd8](https://github.com/valkey-php/valkey-php/commit/36ef4bd8), + [a176f586](https://github.com/valkey-php/valkey-php/commit/a176f586) ([Michael Grunder](https://github.com/michael-grunder)) - EVAL_RO and EVALSHA_RO - [f3a40830](https://github.com/phpredis/phpredis/commit/f3a40830) + [f3a40830](https://github.com/valkey-php/valkey-php/commit/f3a40830) ([Michael Grunder](https://github.com/michael-grunder)) - Implement ZRANGESTORE and add ZRANGE options - [71bcbcb9](https://github.com/phpredis/phpredis/commit/71bcbcb9) + [71bcbcb9](https://github.com/valkey-php/valkey-php/commit/71bcbcb9) ([Michael Grunder](https://github.com/michael-grunder)) - XGROUP DELCONSUMER and ENTRIESREAD - [1343f500](https://github.com/phpredis/phpredis/commit/1343f500) + [1343f500](https://github.com/valkey-php/valkey-php/commit/1343f500) ([Michael Grunder](https://github.com/michael-grunder)) - Expose the transferred number of bytes - [e0a88b7b](https://github.com/phpredis/phpredis/commit/e0a88b7b), - [90828019](https://github.com/phpredis/phpredis/commit/90828019), - [7a4cee2d](https://github.com/phpredis/phpredis/commit/7a4cee2d) + [e0a88b7b](https://github.com/valkey-php/valkey-php/commit/e0a88b7b), + [90828019](https://github.com/valkey-php/valkey-php/commit/90828019), + [7a4cee2d](https://github.com/valkey-php/valkey-php/commit/7a4cee2d) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)), ([Michael Grunder](https://github.com/michael-grunder)) - TOUCH command - [dc1f2398](https://github.com/phpredis/phpredis/commit/dc1f2398) + [dc1f2398](https://github.com/valkey-php/valkey-php/commit/dc1f2398) ([Michael Grunder](https://github.com/michael-grunder)) -- Redis Sentinel TLS support - [f2bb2cdb](https://github.com/phpredis/phpredis/commit/f2bb2cdb) +- Valkey Sentinel TLS support + [f2bb2cdb](https://github.com/valkey-php/valkey-php/commit/f2bb2cdb) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Add the CH, NX, XX arguments to GEOADD - [2bb64038](https://github.com/phpredis/phpredis/commit/2bb64038), - [e8f5b517](https://github.com/phpredis/phpredis/commit/e8f5b517) + [2bb64038](https://github.com/valkey-php/valkey-php/commit/2bb64038), + [e8f5b517](https://github.com/valkey-php/valkey-php/commit/e8f5b517) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Implement SMISMEMBER for RedisCluster - [abfac47b](https://github.com/phpredis/phpredis/commit/abfac47b) +- Implement SMISMEMBER for ValkeyCluster + [abfac47b](https://github.com/valkey-php/valkey-php/commit/abfac47b) ([Michael Grunder](https://github.com/michael-grunder)) - Implement ssubscribe/sunsubscribe - [7644736e](https://github.com/phpredis/phpredis/commit/7644736e) + [7644736e](https://github.com/valkey-php/valkey-php/commit/7644736e) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Implement BLMOVE and add LMOVE/BLMOVE to cluster. - [121e9d9c](https://github.com/phpredis/phpredis/commit/121e9d9c) + [121e9d9c](https://github.com/valkey-php/valkey-php/commit/121e9d9c) ([Michael Grunder](https://github.com/michael-grunder)) -- Implement LPOS for RedisCluster - [7121aaae](https://github.com/phpredis/phpredis/commit/7121aaae) +- Implement LPOS for ValkeyCluster + [7121aaae](https://github.com/valkey-php/valkey-php/commit/7121aaae) ([Michael Grunder](https://github.com/michael-grunder)) -- Implement GEOSEARCH and GEOSEARCHSTORE for RedisCluster. - [fa5d1af9](https://github.com/phpredis/phpredis/commit/fa5d1af9) +- Implement GEOSEARCH and GEOSEARCHSTORE for ValkeyCluster. + [fa5d1af9](https://github.com/valkey-php/valkey-php/commit/fa5d1af9) ([Michael Grunder](https://github.com/michael-grunder)) -- Implement HRANDFIELD for RedisCluster - [e222b85e](https://github.com/phpredis/phpredis/commit/e222b85e) +- Implement HRANDFIELD for ValkeyCluster + [e222b85e](https://github.com/valkey-php/valkey-php/commit/e222b85e) ([Michael Grunder](https://github.com/michael-grunder)) -- Implement COPY for RedisCluster - [40a2c254](https://github.com/phpredis/phpredis/commit/40a2c254) +- Implement COPY for ValkeyCluster + [40a2c254](https://github.com/valkey-php/valkey-php/commit/40a2c254) ([Michael Grunder](https://github.com/michael-grunder)) - Implement new ZSET commands for cluster - [27900f39](https://github.com/phpredis/phpredis/commit/27900f39) + [27900f39](https://github.com/valkey-php/valkey-php/commit/27900f39) ([Michael Grunder](https://github.com/michael-grunder)) - Add cluster support for strict sessions and lazy write - [b6cf6361](https://github.com/phpredis/phpredis/commit/b6cf6361) + [b6cf6361](https://github.com/valkey-php/valkey-php/commit/b6cf6361) ([Michael Grunder](https://github.com/michael-grunder)) - Add function command - [90a0e9cc](https://github.com/phpredis/phpredis/commit/90a0e9cc) + [90a0e9cc](https://github.com/valkey-php/valkey-php/commit/90a0e9cc) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Add FCALL/FCALL_RO commands - [7c46ad2c](https://github.com/phpredis/phpredis/commit/7c46ad2c) + [7c46ad2c](https://github.com/valkey-php/valkey-php/commit/7c46ad2c) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) ### Removed - Remove unused macros - [831d6118](https://github.com/phpredis/phpredis/commit/831d6118) + [831d6118](https://github.com/valkey-php/valkey-php/commit/831d6118) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -## [5.3.7] - 2021-02-15 ([GitHub](https://github.com/phpredis/phpredis/releases/5.3.7), [PECL](https://pecl.php.net/package/redis/5.3.7)) +## [5.3.7] - 2021-02-15 ([GitHub](https://github.com/valkey-php/valkey-php/releases/5.3.7), [PECL](https://pecl.php.net/package/redis/5.3.7)) ### Sponsors :sparkling_heart: @@ -1131,7 +1131,7 @@ and PhpRedis adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm *There were no changes between 5.3.7 and 5.3.7RC2* -## [5.3.7RC2] - 2021-02-12 ([GitHub](https://github.com/phpredis/phpredis/releases/5.3.7RC2), [PECL](https://pecl.php.net/package/redis/5.3.7RC2)) +## [5.3.7RC2] - 2021-02-12 ([GitHub](https://github.com/valkey-php/valkey-php/releases/5.3.7RC2), [PECL](https://pecl.php.net/package/redis/5.3.7RC2)) ### Sponsors :sparkling_heart: @@ -1148,7 +1148,7 @@ and PhpRedis adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm *There were no changes between 5.3.7RC2 and 5.3.7RC1* -## [5.3.7RC1] - 2021-02-02 ([GitHub](https://github.com/phpredis/phpredis/releases/5.3.7RC1), [PECL](https://pecl.php.net/package/redis/5.3.7RC1)) +## [5.3.7RC1] - 2021-02-02 ([GitHub](https://github.com/valkey-php/valkey-php/releases/5.3.7RC1), [PECL](https://pecl.php.net/package/redis/5.3.7RC1)) ### Sponsors :sparkling_heart: @@ -1165,19 +1165,19 @@ and PhpRedis adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Fixed -- Fix RedisArray::[hsz]scan and tests - [08a9d5db](https://github.com/phpredis/phpredis/commit/08a9d5db), - [0264de18](https://github.com/phpredis/phpredis/commit/0264de18), +- Fix ValkeyArray::[hsz]scan and tests + [08a9d5db](https://github.com/valkey-php/valkey-php/commit/08a9d5db), + [0264de18](https://github.com/valkey-php/valkey-php/commit/0264de18), ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)), ([Michael Grunder](https://github.com/michael-grunder)) -- Fix RedisArray::scan - [8689ab1c](https://github.com/phpredis/phpredis/commit/8689ab1c) +- Fix ValkeyArray::scan + [8689ab1c](https://github.com/valkey-php/valkey-php/commit/8689ab1c) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Fix LZF decompression logic - [0719c1ec](https://github.com/phpredis/phpredis/commit/0719c1ec) + [0719c1ec](https://github.com/valkey-php/valkey-php/commit/0719c1ec) ([Michael Grunder](https://github.com/michael-grunder)) -## [5.3.6] - 2021-01-17 ([GitHub](https://github.com/phpredis/phpredis/releases/5.3.6), [PECL](https://pecl.php.net/package/redis/5.3.6)) +## [5.3.6] - 2021-01-17 ([GitHub](https://github.com/valkey-php/valkey-php/releases/5.3.6), [PECL](https://pecl.php.net/package/redis/5.3.6)) ### Sponsors :sparkling_heart: @@ -1194,11 +1194,11 @@ and PhpRedis adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Fixed -- Fix a segfault in RedisArray::del - [d2f2a7d9](https://github.com/phpredis/phpredis/commit/d2f2a7d9) +- Fix a segfault in ValkeyArray::del + [d2f2a7d9](https://github.com/valkey-php/valkey-php/commit/d2f2a7d9) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -## [5.3.5] - 2021-12-18 ([GitHub](https://github.com/phpredis/phpredis/releases/5.3.5), [PECL](https://pecl.php.net/package/redis/5.3.5)) +## [5.3.5] - 2021-12-18 ([GitHub](https://github.com/valkey-php/valkey-php/releases/5.3.5), [PECL](https://pecl.php.net/package/redis/5.3.5)) ### Sponsors :sparkling_heart: @@ -1216,9 +1216,9 @@ and PhpRedis adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Fixed - Fixed typo in cluster_scan_resp - [44affad2](https://github.com/phpredis/phpredis/commit/44affad2) + [44affad2](https://github.com/valkey-php/valkey-php/commit/44affad2) -## [5.3.5RC1] - 2021-11-16 ([GitHub](https://github.com/phpredis/phpredis/releases/5.3.5RC1), [PECL](https://pecl.php.net/package/redis/5.3.5RC1)) +## [5.3.5RC1] - 2021-11-16 ([GitHub](https://github.com/valkey-php/valkey-php/releases/5.3.5RC1), [PECL](https://pecl.php.net/package/redis/5.3.5RC1)) ### Sponsors :sparkling_heart: @@ -1236,45 +1236,45 @@ and PhpRedis adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Fixed - Fixed segfault in redis_setoption_handler - [#2030](https://github.com/phpredis/phpredis/issues/2030) - [692e4e84](https://github.com/phpredis/phpredis/commit/692e4e84) + [#2030](https://github.com/valkey-php/valkey-php/issues/2030) + [692e4e84](https://github.com/valkey-php/valkey-php/commit/692e4e84) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Fix masters array in the event of a cluster failover - [bce692962](https://github.com/phpredis/phpredis/commit/bce692962) - [#2025](https://github.com/phpredis/phpredis/pull/2025) + [bce692962](https://github.com/valkey-php/valkey-php/commit/bce692962) + [#2025](https://github.com/valkey-php/valkey-php/pull/2025) ([Bar Shaul](https://github.com/barshaul)) - Fix 32bit type error - [672dec87f](https://github.com/phpredis/phpredis/commit/672dec87f) - ([#1956](https://github.com/phpredis/phpredis/issues/1956)) + [672dec87f](https://github.com/valkey-php/valkey-php/commit/672dec87f) + ([#1956](https://github.com/valkey-php/valkey-php/issues/1956)) ([Remi Collet](https://github.com/remicollet)) - Fix radix character in certain locales - [#1893](https://github.com/phpredis/phpredis/issues/1893) - [89a871e24](https://github.com/phpredis/phpredis/commit/89a871e24) + [#1893](https://github.com/valkey-php/valkey-php/issues/1893) + [89a871e24](https://github.com/valkey-php/valkey-php/commit/89a871e24) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - ZSTD Validation fix - [6a77ef5cd](https://github.com/phpredis/phpredis/commit/6a77ef5cd) + [6a77ef5cd](https://github.com/valkey-php/valkey-php/commit/6a77ef5cd) ([Michael Grunder](https://github.com/michael-grunder)) - Remove superfluous typecast - [b2871471f](https://github.com/phpredis/phpredis/commit/b2871471f) + [b2871471f](https://github.com/valkey-php/valkey-php/commit/b2871471f) ([Remi Collet](https://github.com/remicollet)) - Updated documentation - [f84168657](https://github.com/phpredis/phpredis/commit/f84168657), - [d017788e7](https://github.com/phpredis/phpredis/commit/d017788e7), - [20ac84710](https://github.com/phpredis/phpredis/commit/20ac84710), - [0adf05260](https://github.com/phpredis/phpredis/commit/0adf05260), - [aee29bf73](https://github.com/phpredis/phpredis/commit/aee29bf73), - [09a095e72](https://github.com/phpredis/phpredis/commit/09a095e72), - [12ffbf33a](https://github.com/phpredis/phpredis/commit/12ffbf33a), - [ff331af98](https://github.com/phpredis/phpredis/commit/ff331af98), - [a6bdb8731](https://github.com/phpredis/phpredis/commit/a6bdb8731), - [305c15840](https://github.com/phpredis/phpredis/commit/305c15840), - [1aa10e93a](https://github.com/phpredis/phpredis/commit/1aa10e93a), - [d78b0c79d](https://github.com/phpredis/phpredis/commit/d78b0c79d), - [c6d37c27c](https://github.com/phpredis/phpredis/commit/c6d37c27c), - [a6303f5b9](https://github.com/phpredis/phpredis/commit/a6303f5b9), - [d144bd2c7](https://github.com/phpredis/phpredis/commit/d144bd2c7), - [a6fb815ef](https://github.com/phpredis/phpredis/commit/a6fb815ef), - [9ef862bc6](https://github.com/phpredis/phpredis/commit/9ef862bc6) + [f84168657](https://github.com/valkey-php/valkey-php/commit/f84168657), + [d017788e7](https://github.com/valkey-php/valkey-php/commit/d017788e7), + [20ac84710](https://github.com/valkey-php/valkey-php/commit/20ac84710), + [0adf05260](https://github.com/valkey-php/valkey-php/commit/0adf05260), + [aee29bf73](https://github.com/valkey-php/valkey-php/commit/aee29bf73), + [09a095e72](https://github.com/valkey-php/valkey-php/commit/09a095e72), + [12ffbf33a](https://github.com/valkey-php/valkey-php/commit/12ffbf33a), + [ff331af98](https://github.com/valkey-php/valkey-php/commit/ff331af98), + [a6bdb8731](https://github.com/valkey-php/valkey-php/commit/a6bdb8731), + [305c15840](https://github.com/valkey-php/valkey-php/commit/305c15840), + [1aa10e93a](https://github.com/valkey-php/valkey-php/commit/1aa10e93a), + [d78b0c79d](https://github.com/valkey-php/valkey-php/commit/d78b0c79d), + [c6d37c27c](https://github.com/valkey-php/valkey-php/commit/c6d37c27c), + [a6303f5b9](https://github.com/valkey-php/valkey-php/commit/a6303f5b9), + [d144bd2c7](https://github.com/valkey-php/valkey-php/commit/d144bd2c7), + [a6fb815ef](https://github.com/valkey-php/valkey-php/commit/a6fb815ef), + [9ef862bc6](https://github.com/valkey-php/valkey-php/commit/9ef862bc6) ([neodisco](https://github.com/neodisco), [Billy Wilson](https://github.com/wilsonwr), [Clément Tessier](https://github.com/ctessier), [wangqr](https://github.com/wangqr), [T. Todua](https://github.com/ttodua), [Naphat Deepar](https://github.com/feverxai), @@ -1283,68 +1283,68 @@ and PhpRedis adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm [Emanuele Filannino](https://github.com/tatekan), [MiRacLe](https://github.com/MiRacLe-RPZ), [Michael Grunder](https://github.com/michael-grunder)) - Travis CI Fixes - [a43f4586e](https://github.com/phpredis/phpredis/commit/a43f4586e), - [4fde8178f](https://github.com/phpredis/phpredis/commit/4fde8178f), - [7bd5415ac](https://github.com/phpredis/phpredis/commit/7bd5415ac), - [fdb8c4bb7](https://github.com/phpredis/phpredis/commit/fdb8c4bb7), - [d4f407470](https://github.com/phpredis/phpredis/commit/d4f407470) + [a43f4586e](https://github.com/valkey-php/valkey-php/commit/a43f4586e), + [4fde8178f](https://github.com/valkey-php/valkey-php/commit/4fde8178f), + [7bd5415ac](https://github.com/valkey-php/valkey-php/commit/7bd5415ac), + [fdb8c4bb7](https://github.com/valkey-php/valkey-php/commit/fdb8c4bb7), + [d4f407470](https://github.com/valkey-php/valkey-php/commit/d4f407470) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Minor fixes/cleanup - [2e190adc1](https://github.com/phpredis/phpredis/commit/2e190adc1), - [99975b592](https://github.com/phpredis/phpredis/commit/99975b592), - [9d0879fa5](https://github.com/phpredis/phpredis/commit/9d0879fa5), - [22b06457b](https://github.com/phpredis/phpredis/commit/22b06457b), + [2e190adc1](https://github.com/valkey-php/valkey-php/commit/2e190adc1), + [99975b592](https://github.com/valkey-php/valkey-php/commit/99975b592), + [9d0879fa5](https://github.com/valkey-php/valkey-php/commit/9d0879fa5), + [22b06457b](https://github.com/valkey-php/valkey-php/commit/22b06457b), ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Fix RedisArray constructor bug - [85dc883ba](https://github.com/phpredis/phpredis/commit/85dc883ba) +- Fix ValkeyArray constructor bug + [85dc883ba](https://github.com/valkey-php/valkey-php/commit/85dc883ba) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) ### Changed - Moved to GitHub Actions - [4d2afa786](https://github.com/phpredis/phpredis/commit/4d2afa786), - [502d09fd5](https://github.com/phpredis/phpredis/commit/502d09fd5) + [4d2afa786](https://github.com/valkey-php/valkey-php/commit/4d2afa786), + [502d09fd5](https://github.com/valkey-php/valkey-php/commit/502d09fd5) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Use more appropriate array iteration macro - [6008900c2](https://github.com/phpredis/phpredis/commit/6008900c2) + [6008900c2](https://github.com/valkey-php/valkey-php/commit/6008900c2) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Clean up session tests - [ab25ae7f3](https://github.com/phpredis/phpredis/commit/ab25ae7f3) + [ab25ae7f3](https://github.com/valkey-php/valkey-php/commit/ab25ae7f3) ([Michael Grunder](https://github.com/michael-grunder)) -- RedisArray refactors - [1250f0001](https://github.com/phpredis/phpredis/commit/1250f0001), - [017b2ea7f](https://github.com/phpredis/phpredis/commit/017b2ea7f), - [37ed3f079](https://github.com/phpredis/phpredis/commit/37ed3f079) +- ValkeyArray refactors + [1250f0001](https://github.com/valkey-php/valkey-php/commit/1250f0001), + [017b2ea7f](https://github.com/valkey-php/valkey-php/commit/017b2ea7f), + [37ed3f079](https://github.com/valkey-php/valkey-php/commit/37ed3f079) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Use zend_parse_parameters_none helper - [a26b14dbe](https://github.com/phpredis/phpredis/commit/a26b14dbe) + [a26b14dbe](https://github.com/valkey-php/valkey-php/commit/a26b14dbe) ([Remi Collet](https://github.com/remicollet)) ### Added - Support for various exponential backoff strategies - [#1986](https://github.com/phpredis/phpredis/commit/#1986), - [#1993](https://github.com/phpredis/phpredis/commit/#1993), - [732eb8dcb](https://github.com/phpredis/phpredis/commit/732eb8dcb) - [05129c3a3](https://github.com/phpredis/phpredis/commit/05129c3a3) - [5bba6a7fc](https://github.com/phpredis/phpredis/commit/5bba6a7fc) + [#1986](https://github.com/valkey-php/valkey-php/commit/#1986), + [#1993](https://github.com/valkey-php/valkey-php/commit/#1993), + [732eb8dcb](https://github.com/valkey-php/valkey-php/commit/732eb8dcb) + [05129c3a3](https://github.com/valkey-php/valkey-php/commit/05129c3a3) + [5bba6a7fc](https://github.com/valkey-php/valkey-php/commit/5bba6a7fc) ([Nathaniel Braun](https://github.com/nbraun-amazon)) - Added experimental support for detecting a dirty connection by trying to determine if the underlying stream is readable. - [d68579562](https://github.com/phpredis/phpredis/commit/d68579562) - [#2013](https://github.com/phpredis/phpredis/issues/2013) + [d68579562](https://github.com/valkey-php/valkey-php/commit/d68579562) + [#2013](https://github.com/valkey-php/valkey-php/issues/2013) ([Michael Grunder](https://github.com/michael-grunder)) - Created distinct compression utility methods (pack/unpack) - [#1939](https://github.com/phpredis/phpredis/issues/1939) - [da2790aec](https://github.com/phpredis/phpredis/commit/da2790aec) + [#1939](https://github.com/valkey-php/valkey-php/issues/1939) + [da2790aec](https://github.com/valkey-php/valkey-php/commit/da2790aec) ([Michael Grunder](https://github.com/michael-grunder)) - SMISMEMBER Command - [#1894](https://github.com/phpredis/phpredis/commit/#1894) - [ae2382472](https://github.com/phpredis/phpredis/commit/ae2382472), - [ed283e1ab](https://github.com/phpredis/phpredis/commit/ed283e1ab), + [#1894](https://github.com/valkey-php/valkey-php/commit/#1894) + [ae2382472](https://github.com/valkey-php/valkey-php/commit/ae2382472), + [ed283e1ab](https://github.com/valkey-php/valkey-php/commit/ed283e1ab), ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -## [5.3.4] - 2021-03-24 ([GitHub](https://github.com/phpredis/phpredis/releases/5.3.4), [PECL](https://pecl.php.net/package/redis/5.3.4)) +## [5.3.4] - 2021-03-24 ([GitHub](https://github.com/valkey-php/valkey-php/releases/5.3.4), [PECL](https://pecl.php.net/package/redis/5.3.4)) ### Sponsors :sparkling_heart: @@ -1358,26 +1358,26 @@ and PhpRedis adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Fixed -- Fix multi/pipeline segfault on Apple silicon [#1917](https://github.com/phpredis/phpredis/issues/1917) - [e0796d48](https://github.com/phpredis/phpredis/commit/e0796d48af18adac2b93982474e7df8de79ec854) +- Fix multi/pipeline segfault on Apple silicon [#1917](https://github.com/valkey-php/valkey-php/issues/1917) + [e0796d48](https://github.com/valkey-php/valkey-php/commit/e0796d48af18adac2b93982474e7df8de79ec854) ([Michael Grunder](https://github.com/michael-grunder)) -- Pass compression flag on HMGET in RedisCluster [#1945](https://github.com/phpredis/phpredis/issues/1945) - [edc724e6](https://github.com/phpredis/phpredis/commit/edc724e6022620414abf4f90256522d03c3160fd) +- Pass compression flag on HMGET in ValkeyCluster [#1945](https://github.com/valkey-php/valkey-php/issues/1945) + [edc724e6](https://github.com/valkey-php/valkey-php/commit/edc724e6022620414abf4f90256522d03c3160fd) ([Adam Olley](https://github.com/aolley)) -- Abide by ZSTD error return constants [#1936](https://github.com/phpredis/phpredis/issues/1936) - [8400ed1c](https://github.com/phpredis/phpredis/pull/1937/commits/8400ed1cb23a22f70727cb60e88ca5397ee10d23) +- Abide by ZSTD error return constants [#1936](https://github.com/valkey-php/valkey-php/issues/1936) + [8400ed1c](https://github.com/valkey-php/valkey-php/pull/1937/commits/8400ed1cb23a22f70727cb60e88ca5397ee10d23) ([Michael Grunder](https://github.com/michael-grunder)) - Fix timing related CI session tests - [9b986bf8](https://github.com/phpredis/phpredis/commit/9b986bf81859f5a5983cd148cb15ee6ce292d288) + [9b986bf8](https://github.com/valkey-php/valkey-php/commit/9b986bf81859f5a5983cd148cb15ee6ce292d288) ([Michael Grunder](https://github.com/michael-grunder)) -## [5.3.3] - 2021-02-01 ([GitHub](https://github.com/phpredis/phpredis/releases/5.3.3), [PECL](https://pecl.php.net/package/redis/5.3.3)) +## [5.3.3] - 2021-02-01 ([GitHub](https://github.com/valkey-php/valkey-php/releases/5.3.3), [PECL](https://pecl.php.net/package/redis/5.3.3)) ### Sponsors :sparkling_heart: - [Audiomack](https://audiomack.com) - [BlueHost](https://bluehost.com) -- [Redis Cache Pro for WordPress](https://wprediscache.com) +- [Valkey Cache Pro for WordPress](https://wprediscache.com) - [Avtandil Kikabidze](https://github.com/akalongman) - [Oleg Babushkin](https://github.com/olbabushkin) - [Zaher Ghaibeh](https://github.com/zaherg) @@ -1386,162 +1386,162 @@ and PhpRedis adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Fixed - Fixed Windows includes for PHP 8 - [270b4db8](https://www.github.com/phpredis//phpredis/commit/270b4db821fcbe9fb881eef83e046f87587c4110) + [270b4db8](https://www.github.com/valkey-php//valkey-php/commit/270b4db821fcbe9fb881eef83e046f87587c4110) ([Jan-E](https://github.com/Jan-E)) - Fix hash_ops for PHP 8.0.1 - [87297cbb](https://www.github.com/phpredis/phpredis/commit/87297cbb4000c88b07e729b9379de321ead74aa2) + [87297cbb](https://www.github.com/valkey-php/valkey-php/commit/87297cbb4000c88b07e729b9379de321ead74aa2) ([defender-11](https://github.com/defender-11)) -- Disable clone for Redis and RedisCluster objects. Presently they segfault. - [cd05a344](https://www.github.com/phpredis/phpredis/commit/87297cbb4000c88b07e729b9379de321ead74aa2) +- Disable clone for Valkey and ValkeyCluster objects. Presently they segfault. + [cd05a344](https://www.github.com/valkey-php/valkey-php/commit/87297cbb4000c88b07e729b9379de321ead74aa2) ([Michael Grunder](https://github.com/michael-grunder)) -## [5.3.2] - 2020-10-22 ([GitHub](https://github.com/phpredis/phpredis/releases/5.3.2), [PECL](https://pecl.php.net/package/redis/5.3.2)) +## [5.3.2] - 2020-10-22 ([GitHub](https://github.com/valkey-php/valkey-php/releases/5.3.2), [PECL](https://pecl.php.net/package/redis/5.3.2)) ### Sponsors :sparkling_heart: - [Audiomack](https://audiomack.com) - [BlueHost](https://bluehost.com) -- [Redis Cache Pro for WordPress](https://wprediscache.com) +- [Valkey Cache Pro for WordPress](https://wprediscache.com) - [Avtandil Kikabidze](https://github.com/akalongman) - [Oleg Babushkin](https://github.com/olbabushkin) ### Fixed - Verify SET options are strings before testing them as strings - [514bc371](https://github.com/phpredis/phpredis/commit/514bc37102c08c1ba7222212b125390f34c35803) + [514bc371](https://github.com/valkey-php/valkey-php/commit/514bc37102c08c1ba7222212b125390f34c35803) ([Michael Grunder](https://github.com/michael-grunder)) -- Fix cluster segfault when dealing with NULL multi bulk replies in RedisCluster - [950e8de8](https://github.com/phpredis/phpredis/commit/950e8de807ba17ecfff62504a6ee7a959a5df714) +- Fix cluster segfault when dealing with NULL multi bulk replies in ValkeyCluster + [950e8de8](https://github.com/valkey-php/valkey-php/commit/950e8de807ba17ecfff62504a6ee7a959a5df714) ([Michael Grunder](https://github.com/michael-grunder), [Alex Offshore](https://github.com/offshore)) - Fix xReadGroup() must return message id - [500916a4](https://github.com/phpredis/phpredis/commit/500916a4d052aa180aa8d27a9e147e64f3ee6303) + [500916a4](https://github.com/valkey-php/valkey-php/commit/500916a4d052aa180aa8d27a9e147e64f3ee6303) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Fix memory leak in rediscluster session handler - [b2cffffc](https://github.com/phpredis/phpredis/commit/b2cffffc107541643bab7eb81751b497bc264639) + [b2cffffc](https://github.com/valkey-php/valkey-php/commit/b2cffffc107541643bab7eb81751b497bc264639) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Fix XInfo() returns false if the stream is empty - [5719c9f7](https://github.com/phpredis/phpredis/commit/5719c9f7ff8ba4595c0f2d82e9549a604d925ed7), - [566fdeeb](https://github.com/phpredis/phpredis/commit/566fdeeb19c8112ac83cf4e47be6928626aa7b37) + [5719c9f7](https://github.com/valkey-php/valkey-php/commit/5719c9f7ff8ba4595c0f2d82e9549a604d925ed7), + [566fdeeb](https://github.com/valkey-php/valkey-php/commit/566fdeeb19c8112ac83cf4e47be6928626aa7b37) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko), [Michael Grunder](https://github.com/michael-grunder)) ### Changed -- Use "%.17g" sprintf format for doubles as done in Redis server. - [32be3006](https://github.com/phpredis/phpredis/commit/32be3006e6d5a9d58636efd53fe02aa22f18c496) +- Use "%.17g" sprintf format for doubles as done in Valkey server. + [32be3006](https://github.com/valkey-php/valkey-php/commit/32be3006e6d5a9d58636efd53fe02aa22f18c496) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Relax requirements on set's expire argument - [36458071](https://github.com/phpredis/phpredis/commit/364580718891de94aac13dc352aa994d531d4272) + [36458071](https://github.com/valkey-php/valkey-php/commit/364580718891de94aac13dc352aa994d531d4272) ([Michael Grunder](https://github.com/michael-grunder)) - Refactor redis_sock_check_liveness - [c5950644](https://github.com/phpredis/phpredis/commit/c5950644e92e61e0c3f38a8ab8a380f707102eb0) + [c5950644](https://github.com/valkey-php/valkey-php/commit/c5950644e92e61e0c3f38a8ab8a380f707102eb0) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - PHP8 compatibility - [a7662da7](https://github.com/phpredis/phpredis/commit/a7662da7924dcbaa74f5f2c6e1dce06b19e64bfc), - [f4a30cb2](https://github.com/phpredis/phpredis/commit/f4a30cb2bda7414b159bf8b1be69dad52ed6f008), - [17848791](https://github.com/phpredis/phpredis/commit/178487919148a0f8f1ad4cae62847bc4ae82ee8c) + [a7662da7](https://github.com/valkey-php/valkey-php/commit/a7662da7924dcbaa74f5f2c6e1dce06b19e64bfc), + [f4a30cb2](https://github.com/valkey-php/valkey-php/commit/f4a30cb2bda7414b159bf8b1be69dad52ed6f008), + [17848791](https://github.com/valkey-php/valkey-php/commit/178487919148a0f8f1ad4cae62847bc4ae82ee8c) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko), [Remi Collet](https://github.com/remicollet)) - Update documentation - [c9ed151d](https://github.com/phpredis/phpredis/commit/c9ed151dbae1532a98c0c9322c9401c47d1da149), - [398c99d9](https://github.com/phpredis/phpredis/commit/398c99d9851b267d9aaaa42c097c5fe54d507a6e) + [c9ed151d](https://github.com/valkey-php/valkey-php/commit/c9ed151dbae1532a98c0c9322c9401c47d1da149), + [398c99d9](https://github.com/valkey-php/valkey-php/commit/398c99d9851b267d9aaaa42c097c5fe54d507a6e) ([Ali Alwash](https://github.com/aalwash), [Gregoire Pineau](https://github.com/lyrixx)) ### Added -- Add `Redis::OPT_NULL_MULTIBULK_AS_NULL` setting to treat NULL multi bulk replies as `NULL` instead of `[]`. - [950e8de8](https://github.com/phpredis/phpredis/commit/950e8de807ba17ecfff62504a6ee7a959a5df714) +- Add `Valkey::OPT_NULL_MULTIBULK_AS_NULL` setting to treat NULL multi bulk replies as `NULL` instead of `[]`. + [950e8de8](https://github.com/valkey-php/valkey-php/commit/950e8de807ba17ecfff62504a6ee7a959a5df714) ([Michael Grunder](https://github.com/michael-grunder), [Alex Offshore](https://github.com/offshore)) - Allow to specify stream context for rediscluster session handler - [a8daaff8](https://github.com/phpredis/phpredis/commit/a8daaff87a055bb6b4fb8702151915f56e144649), - [4fbe7df7](https://github.com/phpredis/phpredis/commit/4fbe7df79b9b0e03f92e8323aed0bda9513bc20a) + [a8daaff8](https://github.com/valkey-php/valkey-php/commit/a8daaff87a055bb6b4fb8702151915f56e144649), + [4fbe7df7](https://github.com/valkey-php/valkey-php/commit/4fbe7df79b9b0e03f92e8323aed0bda9513bc20a) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Add new parameter to RedisCluster to specify stream ssl/tls context. - [f771ea16](https://github.com/phpredis/phpredis/commit/f771ea16b77f39fcca555bec2d952412265197aa), - [72024afe](https://github.com/phpredis/phpredis/commit/72024afed3640230bbd1a017b2a374d12ab88e59) +- Add new parameter to ValkeyCluster to specify stream ssl/tls context. + [f771ea16](https://github.com/valkey-php/valkey-php/commit/f771ea16b77f39fcca555bec2d952412265197aa), + [72024afe](https://github.com/valkey-php/valkey-php/commit/72024afed3640230bbd1a017b2a374d12ab88e59) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Add new parameter to RedisSentinel to specify auth information - [81c502ae](https://github.com/phpredis/phpredis/commit/81c502ae7c0de65d63cd514ee59849c9d1b0b952) +- Add new parameter to ValkeySentinel to specify auth information + [81c502ae](https://github.com/valkey-php/valkey-php/commit/81c502ae7c0de65d63cd514ee59849c9d1b0b952) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -## [5.3.1] - 2020-07-06 ([GitHub](https://github.com/phpredis/phpredis/releases/5.3.1), [PECL](https://pecl.php.net/package/redis/5.3.1)) +## [5.3.1] - 2020-07-06 ([GitHub](https://github.com/valkey-php/valkey-php/releases/5.3.1), [PECL](https://pecl.php.net/package/redis/5.3.1)) ### Sponsors :sparkling_heart: - [Audiomack](https://audiomack.com) - [BlueHost](https://bluehost.com) -- [Redis Cache Pro for WordPress](https://wprediscache.com) +- [Valkey Cache Pro for WordPress](https://wprediscache.com) - [Avtandil Kikabidze](https://github.com/akalongman) ### Fixed - Properly clean up on session start failure - [066cff6a](https://github.com/phpredis/phpredis/commit/066cff6adee03ce05ec5d57083eb7995dfa4344d) + [066cff6a](https://github.com/valkey-php/valkey-php/commit/066cff6adee03ce05ec5d57083eb7995dfa4344d) ([Michael Grunder](https://github.com/michael-grunder)) - Treat NULL as a failure for redis_extract_auth_info - [49428a2f](https://github.com/phpredis/phpredis/commit/49428a2f7072dc30a52db4155aed3d382800b1a6), - [14ac969d](https://github.com/phpredis/phpredis/commit/14ac969da29dbf7203f8db31988ca26b9b45f583) + [49428a2f](https://github.com/valkey-php/valkey-php/commit/49428a2f7072dc30a52db4155aed3d382800b1a6), + [14ac969d](https://github.com/valkey-php/valkey-php/commit/14ac969da29dbf7203f8db31988ca26b9b45f583) ([Michael Grunder](https://github.com/michael-grunder)) - Don't dereference a NULL zend_string or try to efree it - [ff2e160f](https://github.com/phpredis/phpredis/commit/ff2e160f408efdc97676cffaa02093e65c2ad634), - [7fed06f2](https://github.com/phpredis/phpredis/commit/7fed60f248e2249e6cac5c5c3090509aa47647fb) + [ff2e160f](https://github.com/valkey-php/valkey-php/commit/ff2e160f408efdc97676cffaa02093e65c2ad634), + [7fed06f2](https://github.com/valkey-php/valkey-php/commit/7fed60f248e2249e6cac5c5c3090509aa47647fb) ([Michael Grunder](https://github.com/michael-grunder)) - Fix config.m4 messages and test for and include php_hash.h - [83a1b7c5](https://github.com/phpredis/phpredis/commit/83a1b7c5e225abd94cd3459c52bf7d502dfb0979), - [3c56289c](https://github.com/phpredis/phpredis/commit/3c56289c71516a7c0ac81713ef2786c2b9e52274), - [08f202e7](https://github.com/phpredis/phpredis/commit/08f202e775037ccf849d7b933dddb467c9c2ee5f), + [83a1b7c5](https://github.com/valkey-php/valkey-php/commit/83a1b7c5e225abd94cd3459c52bf7d502dfb0979), + [3c56289c](https://github.com/valkey-php/valkey-php/commit/3c56289c71516a7c0ac81713ef2786c2b9e52274), + [08f202e7](https://github.com/valkey-php/valkey-php/commit/08f202e775037ccf849d7b933dddb467c9c2ee5f), ([Remi Collet](https://github.com/remicollet)) ### Added - Add openSUSE installation instructions - [13a168f4](https://github.com/phpredis/phpredis/commit/13a168f42d6639a051d6f829d573dd81bcb97f3a) + [13a168f4](https://github.com/valkey-php/valkey-php/commit/13a168f42d6639a051d6f829d573dd81bcb97f3a) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) ### Removed - Remove EOL Fedora installation instructions - [b4779e6a](https://github.com/phpredis/phpredis/commit/b4779e6a919103bd65fa0e6a0c88e658e05a3e7c) + [b4779e6a](https://github.com/valkey-php/valkey-php/commit/b4779e6a919103bd65fa0e6a0c88e658e05a3e7c) ([Remi Collet](https://github.com/remicollet)) -## [5.3.0] - 2020-06-30 ([GitHub](https://github.com/phpredis/phpredis/releases/tag/5.3.0), [PECL](https://pecl.php.net/package/redis/5.3.0)) +## [5.3.0] - 2020-06-30 ([GitHub](https://github.com/valkey-php/valkey-php/releases/tag/5.3.0), [PECL](https://pecl.php.net/package/redis/5.3.0)) ### Sponsors :sparkling_heart: - [Audiomack](https://audiomack.com) - [BlueHost](https://bluehost.com) -- [Redis Cache Pro for WordPress](https://wprediscache.com) +- [Valkey Cache Pro for WordPress](https://wprediscache.com) - [Avtandil Kikabidze](https://github.com/akalongman) *There were no changes between 5.3.0RC2 and 5.3.0* -## [5.3.0RC2] - 2020-06-26 ([GitHub](https://github.com/phpredis/phpredis/releases/tag/5.3.0RC2), [PECL](https://pecl.php.net/package/redis/5.3.0RC2)) +## [5.3.0RC2] - 2020-06-26 ([GitHub](https://github.com/valkey-php/valkey-php/releases/tag/5.3.0RC2), [PECL](https://pecl.php.net/package/redis/5.3.0RC2)) ### Sponsors :sparkling_heart: - [Audiomack](https://audiomack.com) - [BlueHost](https://bluehost.com) -- [Redis Cache Pro for WordPress](https://wprediscache.com/) +- [Valkey Cache Pro for WordPress](https://wprediscache.com/) - [Avtandil Kikabidze](https://github.com/akalongman) ### Fixed - Fix LZ4 configuration and use pkg-config if we have it - [df398cb0](https://github.com/phpredis/phpredis/commit/df398cb07cd10d870c6805d5834703dc39590b0f) + [df398cb0](https://github.com/valkey-php/valkey-php/commit/df398cb07cd10d870c6805d5834703dc39590b0f) ([Remi Collet](https://github.com/remicollet)) - Make sure persistent pool ID is NULL terminated - [0838b5bd](https://github.com/phpredis/phpredis/commit/0838b5bde7ef25d419868c7e705bf6c70d68ea20), - [57bb95bf](https://github.com/phpredis/phpredis/commit/57bb95bf5a01a2adb74e2bf73bb285488e0d1586) + [0838b5bd](https://github.com/valkey-php/valkey-php/commit/0838b5bde7ef25d419868c7e705bf6c70d68ea20), + [57bb95bf](https://github.com/valkey-php/valkey-php/commit/57bb95bf5a01a2adb74e2bf73bb285488e0d1586) ([Michael Grunder](https://github.com/michael-grunder)) ### Changed - Run LZ4 tests in Travis - [3ba3f06d](https://github.com/phpredis/phpredis/commit/3ba3f06d51ff126eb51dd697381c0e56b38bbcf3) + [3ba3f06d](https://github.com/valkey-php/valkey-php/commit/3ba3f06d51ff126eb51dd697381c0e56b38bbcf3) ([Michael Grunder](https://github.com/michael-grunder)) ## [5.3.0RC1] @@ -1550,130 +1550,130 @@ and PhpRedis adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - [Audiomack.com](https://audiomack.com) - [BlueHost](https://bluehost.com) -- [Redis Cache Pro for WordPress](https://wprediscache.com/) +- [Valkey Cache Pro for WordPress](https://wprediscache.com/) - [Avtandil Kikabidze](https://github.com/akalongman) ### Added -- Support for Redis 6 ACLs - [a311cc4e](https://github.com/phpredis/phpredis/commit/a311cc4ec3cecdbaf83ba66985efa82137e37cc0) +- Support for Valkey 6 ACLs + [a311cc4e](https://github.com/valkey-php/valkey-php/commit/a311cc4ec3cecdbaf83ba66985efa82137e37cc0) ([Michael Grunder](https://github.com/michael-grunder)) - LZ4 Compression - [04def9fb](https://github.com/phpredis/phpredis/commit/04def9fbe2194b3b711362de57260a6cd5216e69) + [04def9fb](https://github.com/valkey-php/valkey-php/commit/04def9fbe2194b3b711362de57260a6cd5216e69) ([Ilia Alshanetsky](https://github.com/iliaal), [Michael Grunder](https://github.com/michael-grunder)) -- Support for new Redis 6 arguments (XINFO FULL, SET KEEPTTL) - [a0c53e0b](https://github.com/phpredis/phpredis/commit/a0c53e0b30e0c6af15cc137415e7d65f6d1867f7), - [f9c7bb57](https://github.com/phpredis/phpredis/commit/f9c7bb5788c39614c23e3bb9ec42ec8d6d5bbaa1) +- Support for new Valkey 6 arguments (XINFO FULL, SET KEEPTTL) + [a0c53e0b](https://github.com/valkey-php/valkey-php/commit/a0c53e0b30e0c6af15cc137415e7d65f6d1867f7), + [f9c7bb57](https://github.com/valkey-php/valkey-php/commit/f9c7bb5788c39614c23e3bb9ec42ec8d6d5bbaa1) ([Victor Kislov](https://github.com/vityank), [Michael Grunder](https://github.com/michael-grunder)) - Support for TLS connections - [890ee0e6](https://github.com/phpredis/phpredis/commit/890ee0e656e545b18179cf247db94a33179ce1ab), - [b0671296](https://github.com/phpredis/phpredis/commit/b067129678264fc1c5c0f611ce1b192e05c14669) + [890ee0e6](https://github.com/valkey-php/valkey-php/commit/890ee0e656e545b18179cf247db94a33179ce1ab), + [b0671296](https://github.com/valkey-php/valkey-php/commit/b067129678264fc1c5c0f611ce1b192e05c14669) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- New option Redis::SCAN_PREFIX, Redis::SCAN_NOPREFIX - [e80600e2](https://github.com/phpredis/phpredis/commit/e80600e244b8442cb7c86e99b067966cd59bf2ee) +- New option Valkey::SCAN_PREFIX, Valkey::SCAN_NOPREFIX + [e80600e2](https://github.com/valkey-php/valkey-php/commit/e80600e244b8442cb7c86e99b067966cd59bf2ee) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Configurable unit test authentication arguments - [e37f38a3](https://github.com/phpredis/phpredis/commit/e37f38a39eb4bece8f49ebd0652112dc992084a0), - [201a9759](https://github.com/phpredis/phpredis/commit/201a97599953a9621bb8eb02dc8d5f08d16499a3) + [e37f38a3](https://github.com/valkey-php/valkey-php/commit/e37f38a39eb4bece8f49ebd0652112dc992084a0), + [201a9759](https://github.com/valkey-php/valkey-php/commit/201a97599953a9621bb8eb02dc8d5f08d16499a3) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko), [Michael Grunder](https://github.com/michael-grunder)) ### Fixed - Improved cluster slot caching mechanism to fix a couple of bugs and make it more efficient. - [5ca4141c](https://github.com/phpredis/phpredis/commit/5ca4141c72e23816f146b49877a6a4b8098b34c6) + [5ca4141c](https://github.com/valkey-php/valkey-php/commit/5ca4141c72e23816f146b49877a6a4b8098b34c6) ([Michael Grunder](https://github.com/michael-grunder)) -- Stop calling Redis constructor when creating a RedisArray - [e41e19a8](https://github.com/phpredis/phpredis/commit/e41e19a8342212ee9cfe35f622804c9870d05ec2) +- Stop calling Valkey constructor when creating a ValkeyArray + [e41e19a8](https://github.com/valkey-php/valkey-php/commit/e41e19a8342212ee9cfe35f622804c9870d05ec2) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Use ZEND_LONG_FMT instead of system `long` - [5bf88124](https://github.com/phpredis/phpredis/commit/5bf881244dd30b5310fcfcaf5bcd8f9e2675bb01) + [5bf88124](https://github.com/valkey-php/valkey-php/commit/5bf881244dd30b5310fcfcaf5bcd8f9e2675bb01) ([Michael Grunder](https://github.com/michael-grunder)) - Use long for SCAN iteration to fix potential overflow - [f13f9b7c](https://github.com/phpredis/phpredis/commit/f13f9b7c7f5e3a7d286b412541199a408a0a98bd) + [f13f9b7c](https://github.com/valkey-php/valkey-php/commit/f13f9b7c7f5e3a7d286b412541199a408a0a98bd) ([Victor Kislov](https://github.com/vityank)) -- Fix config.m4 to test for the variable $PHP_REDIS_JSON and not the literal PHP_REDIS_JSON - [20a3dc72](https://github.com/phpredis/phpredis/commit/20a3dc7251cb0bf450ef2a1cfeeeaeaa10355cd2) +- Fix config.m4 to test for the variable $PHP_VALKEY_JSON and not the literal PHP_VALKEY_JSON + [20a3dc72](https://github.com/valkey-php/valkey-php/commit/20a3dc7251cb0bf450ef2a1cfeeeaeaa10355cd2) ([Mizuki Nakano](https://github.com/mi-nakano)) - Fix compiler warnings - [b9b383f4](https://github.com/phpredis/phpredis/commit/b9b383f49939484dcddf1a5edefdb9d753baa7f8), - [215828e](https://github.com/phpredis/phpredis/commit/215828e3474dfd9ea72fdc6da67aa6bee2d95ddf) + [b9b383f4](https://github.com/valkey-php/valkey-php/commit/b9b383f49939484dcddf1a5edefdb9d753baa7f8), + [215828e](https://github.com/valkey-php/valkey-php/commit/215828e3474dfd9ea72fdc6da67aa6bee2d95ddf) ([Remi Collet](https://github.com/remicollet), [Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Avoid use-after-free of RediSock - [8c45816d](https://github.com/phpredis/phpredis/commit/8c45816dbf4746f6557f83332be874bd78b5ce34) + [8c45816d](https://github.com/valkey-php/valkey-php/commit/8c45816dbf4746f6557f83332be874bd78b5ce34) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Fixed ZADD arginfo - [a8e2b021](https://github.com/phpredis/phpredis/commit/a8e2b021f9eb51ad3ed0cc89064e2f004c56f8ba) + [a8e2b021](https://github.com/valkey-php/valkey-php/commit/a8e2b021f9eb51ad3ed0cc89064e2f004c56f8ba) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) ### Changed -- Store AUTH information in flags RedisSock rather than duplicating information. - [58dab564](https://github.com/phpredis/phpredis/commit/58dab5649fcc2cc63f5a29df83f783e154d7fa22) +- Store AUTH information in flags ValkeySock rather than duplicating information. + [58dab564](https://github.com/valkey-php/valkey-php/commit/58dab5649fcc2cc63f5a29df83f783e154d7fa22) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Refactor redis_sock_get_connection_pool logic. - [73212e1](https://github.com/phpredis/phpredis/commit/73212e141403ec47441142fe1c7fd5fad24f6720) + [73212e1](https://github.com/valkey-php/valkey-php/commit/73212e141403ec47441142fe1c7fd5fad24f6720) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Updated documentation to show LPUSH and RPUSH are variadic and fixed DEL documentation. - [92f8dde1](https://github.com/phpredis/phpredis/commit/92f8dde1c996d4e1c3d79226b888119307612c40) + [92f8dde1](https://github.com/valkey-php/valkey-php/commit/92f8dde1c996d4e1c3d79226b888119307612c40) ([Michael Grunder](https://github.com/michael-grunder)) - Authenticate in redis_server_sock_open - [4ef465b5](https://github.com/phpredis/phpredis/commit/4ef465b57325d2d93234fd66af06a7091ce7d1ea) + [4ef465b5](https://github.com/valkey-php/valkey-php/commit/4ef465b57325d2d93234fd66af06a7091ce7d1ea) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Dynamically include json.so in unit tests based on configuration - [0ce7ca2f](https://github.com/phpredis/phpredis/commit/0ce7ca2fb1eb2f3c445487957a49b70ad8d4ecb6) + [0ce7ca2f](https://github.com/valkey-php/valkey-php/commit/0ce7ca2fb1eb2f3c445487957a49b70ad8d4ecb6) (([Michael Grunder](https://github.com/michael-grunder)) -- Update save_path logic in Redis Cluster session unit tests - [dd66fce](https://github.com/phpredis/phpredis/commit/dd66fceeb232f9e1fb0a26373949e810180dc5fc) +- Update save_path logic in Valkey Cluster session unit tests + [dd66fce](https://github.com/valkey-php/valkey-php/commit/dd66fceeb232f9e1fb0a26373949e810180dc5fc) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Refactoring various bits of logic - [bbcf32a3](https://github.com/phpredis/phpredis/commit/bbcf32a37fa856ba0b50b489ba05bd3d43800fcc), - [a42cf189](https://github.com/phpredis/phpredis/commit/a42cf189a776fc43acf47ca519f1d7385cc27f2f), - [460c8f29](https://github.com/phpredis/phpredis/commit/460c8f29239c263e15a093c9bcdb6fb24587ec7d), - [b7f9df75](https://github.com/phpredis/phpredis/commit/b7f9df758b30187864012d5cd831dbbc5fa053d0), + [bbcf32a3](https://github.com/valkey-php/valkey-php/commit/bbcf32a37fa856ba0b50b489ba05bd3d43800fcc), + [a42cf189](https://github.com/valkey-php/valkey-php/commit/a42cf189a776fc43acf47ca519f1d7385cc27f2f), + [460c8f29](https://github.com/valkey-php/valkey-php/commit/460c8f29239c263e15a093c9bcdb6fb24587ec7d), + [b7f9df75](https://github.com/valkey-php/valkey-php/commit/b7f9df758b30187864012d5cd831dbbc5fa053d0), ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Use the portable `ZEND_LONG_FORMAT` family instead of C format specifiers - [b9b383f4](https://github.com/phpredis/phpredis/commit/b9b383f4) + [b9b383f4](https://github.com/valkey-php/valkey-php/commit/b9b383f4) ([Remi Collet](https://github.com/remicollet)) - PHP 8 compatibility - [9ee94ca4](https://github.com/phpredis/phpredis/commit/9ee94ca4), - [7e4c7b3e](https://github.com/phpredis/phpredis/commit/7e4c7b3e) + [9ee94ca4](https://github.com/valkey-php/valkey-php/commit/9ee94ca4), + [7e4c7b3e](https://github.com/valkey-php/valkey-php/commit/7e4c7b3e) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Refactor PHPREDIS_GET_OBJECT macro - [d5dadaf6](https://github.com/phpredis/phpredis/commit/d5dadaf6), - [190c0d34](https://github.com/phpredis/phpredis/commit/190c0d34) +- Refactor PHPVALKEY_GET_OBJECT macro + [d5dadaf6](https://github.com/valkey-php/valkey-php/commit/d5dadaf6), + [190c0d34](https://github.com/valkey-php/valkey-php/commit/190c0d34) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Fix documentation to show lPush and rPush are variadic - [6808cd6a](https://github.com/phpredis/phpredis/commit/6808cd6a) + [6808cd6a](https://github.com/valkey-php/valkey-php/commit/6808cd6a) ([Michel Grunder](https://github.com/michael-grunder)) --- -## [5.2.2] - 2020-05-05 ([GitHub](https://github.com/phpredis/phpredis/releases/tag/5.2.2), [PECL](https://pecl.php.net/package/redis/5.2.2)) +## [5.2.2] - 2020-05-05 ([GitHub](https://github.com/valkey-php/valkey-php/releases/tag/5.2.2), [PECL](https://pecl.php.net/package/redis/5.2.2)) ### Sponsors :sparkling_heart: @@ -1683,16 +1683,16 @@ and PhpRedis adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Changed - Inexpensive liveness check, and making ECHO optional - [56898f81](https://github.com/phpredis/phpredis/commit/56898f81) + [56898f81](https://github.com/valkey-php/valkey-php/commit/56898f81) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Move `AUTH` to `redis_sock_server_open` - [80f2529b](https://github.com/phpredis/phpredis/commit/80f2529b) + [80f2529b](https://github.com/valkey-php/valkey-php/commit/80f2529b) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) --- -## [5.2.1] - 2020-03-19 ([GitHub](https://github.com/phpredis/phpredis/releases/tag/5.2.1), [PECL](https://pecl.php.net/package/redis/5.2.1)) +## [5.2.1] - 2020-03-19 ([GitHub](https://github.com/valkey-php/valkey-php/releases/tag/5.2.1), [PECL](https://pecl.php.net/package/redis/5.2.1)) ### Sponsors :sparkling_heart: @@ -1701,21 +1701,21 @@ and PhpRedis adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Fixed -- Fix arginfo for Redis::zadd - [a8e2b021](https://github.com/phpredis/phpredis/commit/a8e2b021) +- Fix arginfo for Valkey::zadd + [a8e2b021](https://github.com/valkey-php/valkey-php/commit/a8e2b021) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Fix segfault on closing persistent stream - [b7f9df75](https://github.com/phpredis/phpredis/commit/b7f9df75) + [b7f9df75](https://github.com/valkey-php/valkey-php/commit/b7f9df75) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) --- -## [5.2.0] - 2020-03-02 ([GitHub](https://github.com/phpredis/phpredis/releases/tag/5.2.0), [PECL](https://pecl.php.net/package/redis/5.2.0)) +## [5.2.0] - 2020-03-02 ([GitHub](https://github.com/valkey-php/valkey-php/releases/tag/5.2.0), [PECL](https://pecl.php.net/package/redis/5.2.0)) *There were no changes between 5.2.0RC2 and 5.2.0* -## [5.2.0RC2] - 2020-02-21 ([GitHub](https://github.com/phpredis/phpredis/releases/tag/5.2.0RC2), [PECL](https://pecl.php.net/package/redis/5.2.0RC2)) +## [5.2.0RC2] - 2020-02-21 ([GitHub](https://github.com/valkey-php/valkey-php/releases/tag/5.2.0RC2), [PECL](https://pecl.php.net/package/redis/5.2.0RC2)) ### Sponsors :sparkling_heart: @@ -1724,22 +1724,22 @@ and PhpRedis adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Fixed -- Include RedisSentinelTest.php in package.xml! - [eddbfc8f](https://github.com/phpredis/phpredis/commit/eddbfc8f) +- Include ValkeySentinelTest.php in package.xml! + [eddbfc8f](https://github.com/valkey-php/valkey-php/commit/eddbfc8f) ([Michel Grunder](https://github.com/michael-grunder)) - Fix -Wmaybe-uninitialized warning - [740b8c87](https://github.com/phpredis/phpredis/commit/740b8c87) + [740b8c87](https://github.com/valkey-php/valkey-php/commit/740b8c87) ([Remi Collet](https://github.com/remicollet)) - Fix improper destructor when zipping values and scores - [371ae7ae](https://github.com/phpredis/phpredis/commit/371ae7ae) + [371ae7ae](https://github.com/valkey-php/valkey-php/commit/371ae7ae) - Use php_rand instead of php_mt_rand for liveness challenge string - [9ef2ed89](https://github.com/phpredis/phpredis/commit/9ef2ed89) + [9ef2ed89](https://github.com/valkey-php/valkey-php/commit/9ef2ed89) ([Michael Grunder](https://github.com/michael-grunder)) -## [5.2.0RC1] - 2020-02-15 ([GitHub](https://github.com/phpredis/phpredis/releases/tag/5.2.0RC1), [PECL](https://pecl.php.net/package/redis/5.2.0RC1)) +## [5.2.0RC1] - 2020-02-15 ([GitHub](https://github.com/valkey-php/valkey-php/releases/tag/5.2.0RC1), [PECL](https://pecl.php.net/package/redis/5.2.0RC1)) ### Sponsors :sparkling_heart: @@ -1748,54 +1748,54 @@ and PhpRedis adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Added - Added challenge/response mechanism to ensure persistent connections are not in a bad state - [a5f95925](https://github.com/phpredis/phpredis/commit/a5f95925), - [25cdaee6](https://github.com/phpredis/phpredis/commit/25cdaee6), - [7b6072e0](https://github.com/phpredis/phpredis/commit/7b6072e0), - [99ebd0cc](https://github.com/phpredis/phpredis/commit/99ebd0cc), - [3243f426](https://github.com/phpredis/phpredis/commit/3243f426) + [a5f95925](https://github.com/valkey-php/valkey-php/commit/a5f95925), + [25cdaee6](https://github.com/valkey-php/valkey-php/commit/25cdaee6), + [7b6072e0](https://github.com/valkey-php/valkey-php/commit/7b6072e0), + [99ebd0cc](https://github.com/valkey-php/valkey-php/commit/99ebd0cc), + [3243f426](https://github.com/valkey-php/valkey-php/commit/3243f426) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko), [Michael Grunder](https://github.com/michael-grunder)) -- Experimental support for RedisSentinel - [90cb69f3](https://github.com/phpredis/phpredis/commit/90cb69f3), - [c94e28f1](https://github.com/phpredis/phpredis/commit/c94e28f1), - [46da22b0](https://github.com/phpredis/phpredis/commit/46da22b0), - [5a609fa4](https://github.com/phpredis/phpredis/commit/5a609fa4), - [383779ed](https://github.com/phpredis/phpredis/commit/383779ed) +- Experimental support for ValkeySentinel + [90cb69f3](https://github.com/valkey-php/valkey-php/commit/90cb69f3), + [c94e28f1](https://github.com/valkey-php/valkey-php/commit/c94e28f1), + [46da22b0](https://github.com/valkey-php/valkey-php/commit/46da22b0), + [5a609fa4](https://github.com/valkey-php/valkey-php/commit/5a609fa4), + [383779ed](https://github.com/valkey-php/valkey-php/commit/383779ed) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) ### Fixed - Fixed ASK redirection logic - [ba73fbee](https://github.com/phpredis/phpredis/commit/ba73fbee) + [ba73fbee](https://github.com/valkey-php/valkey-php/commit/ba73fbee) ([Michael Grunder](https://github.com/michael-grunder)) - Create specific 'test skipped' exception - [c3d83d44](https://github.com/phpredis/phpredis/commit/c3d83d44) + [c3d83d44](https://github.com/valkey-php/valkey-php/commit/c3d83d44) ([Michael Grunder](https://github.com/michael-grunder)) -- Fixed memory leaks in RedisCluster - [a107c9fc](https://github.com/phpredis/phpredis/commit/a107c9fc) +- Fixed memory leaks in ValkeyCluster + [a107c9fc](https://github.com/valkey-php/valkey-php/commit/a107c9fc) ([Michael Grunder](https://github.com/michael-grunder)) - Fixes for session lifetime values that underflow or overflow - [7a79ad9c](https://github.com/phpredis/phpredis/commit/7a79ad9c), - [3c48a332](https://github.com/phpredis/phpredis/commit/3c48a332) + [7a79ad9c](https://github.com/valkey-php/valkey-php/commit/7a79ad9c), + [3c48a332](https://github.com/valkey-php/valkey-php/commit/3c48a332) ([Michael Grunder](https://github.com/michael-grunder)) -- Enables slot caching for Redis Cluster - [23b1a9d8](https://github.com/phpredis/phpredis/commit/23b1a9d8) +- Enables slot caching for Valkey Cluster + [23b1a9d8](https://github.com/valkey-php/valkey-php/commit/23b1a9d8) ([Michael Booth](https://github.com/Michael03)) - Housekeeping (spelling, doc changes, etc) - [23f9de30](https://github.com/phpredis/phpredis/commit/23f9de30), - [d07a8df6](https://github.com/phpredis/phpredis/commit/d07a8df6), - [2d39b48d](https://github.com/phpredis/phpredis/commit/2d39b48d), - [0ef488fc](https://github.com/phpredis/phpredis/commit/0ef488fc), - [2c35e435](https://github.com/phpredis/phpredis/commit/2c35e435), - [f52bd8a8](https://github.com/phpredis/phpredis/commit/f52bd8a8), - [2ddc5f21](https://github.com/phpredis/phpredis/commit/2ddc5f21), - [1ff7dfb7](https://github.com/phpredis/phpredis/commit/1ff7dfb7), - [db446138](https://github.com/phpredis/phpredis/commit/db446138) + [23f9de30](https://github.com/valkey-php/valkey-php/commit/23f9de30), + [d07a8df6](https://github.com/valkey-php/valkey-php/commit/d07a8df6), + [2d39b48d](https://github.com/valkey-php/valkey-php/commit/2d39b48d), + [0ef488fc](https://github.com/valkey-php/valkey-php/commit/0ef488fc), + [2c35e435](https://github.com/valkey-php/valkey-php/commit/2c35e435), + [f52bd8a8](https://github.com/valkey-php/valkey-php/commit/f52bd8a8), + [2ddc5f21](https://github.com/valkey-php/valkey-php/commit/2ddc5f21), + [1ff7dfb7](https://github.com/valkey-php/valkey-php/commit/1ff7dfb7), + [db446138](https://github.com/valkey-php/valkey-php/commit/db446138) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko), [Tyson Andre](https://github.com/TysonAndre), [Michael Grunder](https://github.com/michael-grunder), [Paul DelRe](https://github.com/pdelre), [Tyson Andre](https://github.com/TysonAndre)) @@ -1803,481 +1803,481 @@ and PhpRedis adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Changed - Support TYPE argument for SCAN - [8eb39a26](https://github.com/phpredis/phpredis/commit/8eb39a26) - [b1724b84](https://github.com/phpredis/phpredis/commit/b1724b84) - [53fb36c9](https://github.com/phpredis/phpredis/commit/53fb36c9) - [544e641b](https://github.com/phpredis/phpredis/commit/544e641b) + [8eb39a26](https://github.com/valkey-php/valkey-php/commit/8eb39a26) + [b1724b84](https://github.com/valkey-php/valkey-php/commit/b1724b84) + [53fb36c9](https://github.com/valkey-php/valkey-php/commit/53fb36c9) + [544e641b](https://github.com/valkey-php/valkey-php/commit/544e641b) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) --- -## [5.1.1] - 2019-11-11 ([GitHub](https://github.com/phpredis/phpredis/releases/tag/5.1.1), [PECL](https://pecl.php.net/package/redis/5.1.1)) +## [5.1.1] - 2019-11-11 ([GitHub](https://github.com/valkey-php/valkey-php/releases/tag/5.1.1), [PECL](https://pecl.php.net/package/redis/5.1.1)) ### Fixed - Fix fail to connect to redis through unix socket - [2bae8010](https://github.com/phpredis/phpredis/commit/2bae8010), - [9f4ededa](https://github.com/phpredis/phpredis/commit/9f4ededa) + [2bae8010](https://github.com/valkey-php/valkey-php/commit/2bae8010), + [9f4ededa](https://github.com/valkey-php/valkey-php/commit/9f4ededa) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko), [Michael Grunder](https://github.com/michael-grunder)) --- -## [5.1.0] - 2019-10-31 ([GitHub](https://github.com/phpredis/phpredis/releases/tag/5.1.0), [PECL](https://pecl.php.net/package/redis/5.1.0)) +## [5.1.0] - 2019-10-31 ([GitHub](https://github.com/valkey-php/valkey-php/releases/tag/5.1.0), [PECL](https://pecl.php.net/package/redis/5.1.0)) ### Added - Add optional support for Zstd compression, using `--enable-redis-zstd`. This requires libzstd version >= 1.3.0 - [2abc61da](https://github.com/phpredis/phpredis/commit/2abc61da) + [2abc61da](https://github.com/valkey-php/valkey-php/commit/2abc61da) ([Remi Collet](https://github.com/remicollet)) - Add documentation for zpopmin and zpopmax - [99ec24b3](https://github.com/phpredis/phpredis/commit/99ec24b3), - [4ab1f940](https://github.com/phpredis/phpredis/commit/4ab1f940) + [99ec24b3](https://github.com/valkey-php/valkey-php/commit/99ec24b3), + [4ab1f940](https://github.com/valkey-php/valkey-php/commit/4ab1f940) ([alexander-schranz](https://github.com/alexander-schranz)) - Allow to specify scheme for session handler. - [53a8bcc7](https://github.com/phpredis/phpredis/commit/53a8bcc7) + [53a8bcc7](https://github.com/valkey-php/valkey-php/commit/53a8bcc7) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) ### Changed - Refactor redis_session - [91a8e734](https://github.com/phpredis/phpredis/commit/91a8e734), - [978c3074](https://github.com/phpredis/phpredis/commit/978c3074) + [91a8e734](https://github.com/valkey-php/valkey-php/commit/91a8e734), + [978c3074](https://github.com/valkey-php/valkey-php/commit/978c3074) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Fix overallocation in RedisCluster directed node commands - [cf93649](https://github.com/phpredis/phpredis/commit/cf93649) +- Fix overallocation in ValkeyCluster directed node commands + [cf93649](https://github.com/valkey-php/valkey-php/commit/cf93649) ([Michael Grunder](https://github.com/michael-grunder)) - Also attach slaves when caching cluster slots - [0d6d3fdd](https://github.com/phpredis/phpredis/commit/0d6d3fdd), - [b114fc26](https://github.com/phpredis/phpredis/commit/b114fc26) + [0d6d3fdd](https://github.com/valkey-php/valkey-php/commit/0d6d3fdd), + [b114fc26](https://github.com/valkey-php/valkey-php/commit/b114fc26) ([Michael Grunder](https://github.com/michael-grunder)) - Use zend_register_persistent_resource_ex for connection pooling - [fdada7ae](https://github.com/phpredis/phpredis/commit/fdada7ae), - [7c6c43a6](https://github.com/phpredis/phpredis/commit/7c6c43a6) + [fdada7ae](https://github.com/valkey-php/valkey-php/commit/fdada7ae), + [7c6c43a6](https://github.com/valkey-php/valkey-php/commit/7c6c43a6) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) ### Fixed -- Fix regression for multihost_distribute_call added in [112c77e3](https://github.com/phpredis/phpredis/commit/112c77e3) - [fbe0f804](https://github.com/phpredis/phpredis/commit/fbe0f804) +- Fix regression for multihost_distribute_call added in [112c77e3](https://github.com/valkey-php/valkey-php/commit/112c77e3) + [fbe0f804](https://github.com/valkey-php/valkey-php/commit/fbe0f804) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Revert "fix regression for conntecting to ports > 32767" added in [1f41da64](https://github.com/phpredis/phpredis/commit/1f41da64) and add another fix - [17b139d8](https://github.com/phpredis/phpredis/commit/17b139d8), - [7ef17ce1](https://github.com/phpredis/phpredis/commit/7ef17ce1) +- Revert "fix regression for conntecting to ports > 32767" added in [1f41da64](https://github.com/valkey-php/valkey-php/commit/1f41da64) and add another fix + [17b139d8](https://github.com/valkey-php/valkey-php/commit/17b139d8), + [7ef17ce1](https://github.com/valkey-php/valkey-php/commit/7ef17ce1) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Fix regression for conntecting to unix sockets with relative path added in [1f41da64](https://github.com/phpredis/phpredis/commit/1f41da64) - [17b139d8](https://github.com/phpredis/phpredis/commit/17b139d8), - [7ef17ce1](https://github.com/phpredis/phpredis/commit/7ef17ce1) +- Fix regression for conntecting to unix sockets with relative path added in [1f41da64](https://github.com/valkey-php/valkey-php/commit/1f41da64) + [17b139d8](https://github.com/valkey-php/valkey-php/commit/17b139d8), + [7ef17ce1](https://github.com/valkey-php/valkey-php/commit/7ef17ce1) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Fix unix-socket detection logic broken in [418428fa](https://github.com/phpredis/phpredis/commit/418428fa) - [a080b73f](https://github.com/phpredis/phpredis/commit/a080b73f) +- Fix unix-socket detection logic broken in [418428fa](https://github.com/valkey-php/valkey-php/commit/418428fa) + [a080b73f](https://github.com/valkey-php/valkey-php/commit/a080b73f) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Fix memory leak and bug with getLastError for redis_mbulk_reply_assoc and redis_mbulk_reply_zipped. - [7f42d628](https://github.com/phpredis/phpredis/commit/7f42d628), - [3a622a07](https://github.com/phpredis/phpredis/commit/3a622a07) + [7f42d628](https://github.com/valkey-php/valkey-php/commit/7f42d628), + [3a622a07](https://github.com/valkey-php/valkey-php/commit/3a622a07) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)), ([Michael Grunder](https://github.com/michael-grunder)) - Fix bug with password contain "#" for redis_session - [2bb08680](https://github.com/phpredis/phpredis/commit/2bb08680) + [2bb08680](https://github.com/valkey-php/valkey-php/commit/2bb08680) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Missing null byte in PHP_MINFO_FUNCTION - [8bc2240c](https://github.com/phpredis/phpredis/commit/8bc2240c) + [8bc2240c](https://github.com/valkey-php/valkey-php/commit/8bc2240c) ([Remi Collet](https://github.com/remicollet)) ### Removed - Dead code generic_unsubscribe_cmd - [8ee4abbc](https://github.com/phpredis/phpredis/commit/8ee4abbc) + [8ee4abbc](https://github.com/valkey-php/valkey-php/commit/8ee4abbc) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) --- -## [5.0.2] - 2019-07-29 ([GitHub](https://github.com/phpredis/phpredis/releases/tag/5.0.2), [PECL](https://pecl.php.net/package/redis/5.0.2)) +## [5.0.2] - 2019-07-29 ([GitHub](https://github.com/valkey-php/valkey-php/releases/tag/5.0.2), [PECL](https://pecl.php.net/package/redis/5.0.2)) ### Fixed - Fix regression for conntecting to ports > 32767 - [1f41da64](https://github.com/phpredis/phpredis/commit/1f41da64), + [1f41da64](https://github.com/valkey-php/valkey-php/commit/1f41da64), ([Owen Smith](https://github.com/orls)) -- RedisCluster segfaults after second connection with cache_slots enabled - [f52cd237](https://github.com/phpredis/phpredis/commit/f52cd237), - [cb5d6b94](https://github.com/phpredis/phpredis/commit/cb5d6b94) +- ValkeyCluster segfaults after second connection with cache_slots enabled + [f52cd237](https://github.com/valkey-php/valkey-php/commit/f52cd237), + [cb5d6b94](https://github.com/valkey-php/valkey-php/commit/cb5d6b94) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko), [Michael Grunder](https://github.com/michael-grunder)) ### Changed - Cleanup TSRMLS_* usage - [94380227](https://github.com/phpredis/phpredis/commit/94380227) + [94380227](https://github.com/valkey-php/valkey-php/commit/94380227) ([Remi Collet](https://github.com/remicollet)) - Replace ulong with zend_ulong - [b4eb158a](https://github.com/phpredis/phpredis/commit/b4eb158a) + [b4eb158a](https://github.com/valkey-php/valkey-php/commit/b4eb158a) ([Remi Collet](https://github.com/remicollet)) - Replace uint with uint32_t - [d6fc5c73](https://github.com/phpredis/phpredis/commit/d6fc5c73) + [d6fc5c73](https://github.com/valkey-php/valkey-php/commit/d6fc5c73) ([Remi Collet](https://github.com/remicollet)) --- -## [5.0.1] - 2019-07-12 ([GitHub](https://github.com/phpredis/phpredis/releases/tag/5.0.1), [PECL](https://pecl.php.net/package/redis/5.0.1)) +## [5.0.1] - 2019-07-12 ([GitHub](https://github.com/valkey-php/valkey-php/releases/tag/5.0.1), [PECL](https://pecl.php.net/package/redis/5.0.1)) ### Fixed -- RedisCluster segfaults after second connection with cache_slots enabled - [327cf0bd](https://github.com/phpredis/phpredis/commit/327cf0bd) +- ValkeyCluster segfaults after second connection with cache_slots enabled + [327cf0bd](https://github.com/valkey-php/valkey-php/commit/327cf0bd) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) --- -## [5.0.0] - 2019-07-02 ([GitHub](https://github.com/phpredis/phpredis/releases/tag/5.0.0), [PECL](https://pecl.php.net/package/redis/5.0.0)) +## [5.0.0] - 2019-07-02 ([GitHub](https://github.com/valkey-php/valkey-php/releases/tag/5.0.0), [PECL](https://pecl.php.net/package/redis/5.0.0)) This release contains important improvements and breaking changes. The most -interesting are: drop PHP5 support, RedisCluster slots caching, JSON and msgpack -serializers, soft deprecation of non-Redis commands. +interesting are: drop PHP5 support, ValkeyCluster slots caching, JSON and msgpack +serializers, soft deprecation of non-Valkey commands. ### Breaking Changes - [Nullable xReadGroup COUNT and BLOCK arguments](#brk500-xreadgroup) -- [RedisArray exception now includes host information](#brk500-exception-host) +- [ValkeyArray exception now includes host information](#brk500-exception-host) - [zRange now conforms to zRangeByScore to get scores](#brk500-zrange-withscores) ### Added -- Adds OPT_REPLY_LITERAL for rawCommand and EVAL [5cb30fb2](https://www.github.com/phpredis/phpredis/commit/5cb30fb2) +- Adds OPT_REPLY_LITERAL for rawCommand and EVAL [5cb30fb2](https://www.github.com/valkey-php/valkey-php/commit/5cb30fb2) ([Michael Grunder](https://github.com/michael-grunder)) -- JSON serializer [98bd2886](https://www.github.com/phpredis/phpredis/commit/98bd2886), - [96c57139](https://www.github.com/phpredis/phpredis/commit/96c57139), - [235a27](https://www.github.com/phpredis/phpredis/commit/235a27) +- JSON serializer [98bd2886](https://www.github.com/valkey-php/valkey-php/commit/98bd2886), + [96c57139](https://www.github.com/valkey-php/valkey-php/commit/96c57139), + [235a27](https://www.github.com/valkey-php/valkey-php/commit/235a27) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko), [Michael Grunder](https://github.com/michael-grunder)) -- msgpack serializer [d5b8f833](https://www.github.com/phpredis/phpredis/commit/d5b8f833), - [545250f3](https://www.github.com/phpredis/phpredis/commit/545250f3), - [52bae8ab](https://www.github.com/phpredis/phpredis/commit/52bae8ab) +- msgpack serializer [d5b8f833](https://www.github.com/valkey-php/valkey-php/commit/d5b8f833), + [545250f3](https://www.github.com/valkey-php/valkey-php/commit/545250f3), + [52bae8ab](https://www.github.com/valkey-php/valkey-php/commit/52bae8ab) ([@bgort](https://github.com/bgort), [Pavlo Yatsukhnenko](https://github.com/yatsukhnenko), [Michael Grunder](https://github.com/michael-grunder)) -- Add support for STREAM to the type command [d7450b2f](https://www.github.com/phpredis/phpredis/commit/d7450b2f), - [068ce978](https://www.github.com/phpredis/phpredis/commit/068ce978), [8a45d18c](https://www.github.com/phpredis/phpredis/commit/8a45d18c) +- Add support for STREAM to the type command [d7450b2f](https://www.github.com/valkey-php/valkey-php/commit/d7450b2f), + [068ce978](https://www.github.com/valkey-php/valkey-php/commit/068ce978), [8a45d18c](https://www.github.com/valkey-php/valkey-php/commit/8a45d18c) ([Michael Grunder](https://github.com/michael-grunder), [Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Add Cluster slots caching [9f0d7bc0](https://www.github.com/phpredis/phpredis/commit/9f0d7bc0), - [ea081e05](https://www.github.com/phpredis/phpredis/commit/ea081e05) ([Michael Grunder](https://github.com/michael-grunder)) +- Add Cluster slots caching [9f0d7bc0](https://www.github.com/valkey-php/valkey-php/commit/9f0d7bc0), + [ea081e05](https://www.github.com/valkey-php/valkey-php/commit/ea081e05) ([Michael Grunder](https://github.com/michael-grunder)) ### Changed - Add server address to exception message. This changes the exception message from `read error on connection` to `read error on connection to :` or `read error on connection to ` so code matching the exception string might break. - [e8fb49be](https://www.github.com/phpredis/phpredis/commit/e8fb49be), - [34d6403d](https://www.github.com/phpredis/phpredis/commit/34d6403d) + [e8fb49be](https://www.github.com/valkey-php/valkey-php/commit/e8fb49be), + [34d6403d](https://www.github.com/valkey-php/valkey-php/commit/34d6403d) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Allow to specify server address as `schema://host` [418428fa](https://www.github.com/phpredis/phpredis/commit/418428fa) +- Allow to specify server address as `schema://host` [418428fa](https://www.github.com/valkey-php/valkey-php/commit/418428fa) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)). -- Update Fedora installation instructions [90aa067c](https://www.github.com/phpredis/phpredis/commit/90aa067c) +- Update Fedora installation instructions [90aa067c](https://www.github.com/valkey-php/valkey-php/commit/90aa067c) ([@remicollet](https://github.com/remicollet)) -- Enable connection pooling by default [8206b147](https://www.github.com/phpredis/phpredis/commit/8206b147) +- Enable connection pooling by default [8206b147](https://www.github.com/valkey-php/valkey-php/commit/8206b147) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Allow PING to take an optional argument. PING now returns `true` instead of "+PONG" [6e494170](https://www.github.com/phpredis/phpredis/commit/6e494170) +- Allow PING to take an optional argument. PING now returns `true` instead of "+PONG" [6e494170](https://www.github.com/valkey-php/valkey-php/commit/6e494170) ([Michael Grunder](https://github.com/michael-grunder)) - Allow ZRANGE to be called either with `true` or `['withscores' => true]` - [19f3efcf](https://www.github.com/phpredis/phpredis/commit/19f3efcf) ([Michael Grunder](https://github.com/michael-grunder)) + [19f3efcf](https://www.github.com/valkey-php/valkey-php/commit/19f3efcf) ([Michael Grunder](https://github.com/michael-grunder)) - Documentation improvements ([@alexander-schranz](https://github.com/alexander-schranz), [@cookieguru](https://github.com/cookieguru), [Pavlo Yatsukhnenko](https://github.com/yatsukhnenko), [Michael Grunder](https://github.com/michael-grunder)) ### Deprecated -- Soft deprecate methods that aren't actually Redis commands [a81b4f2d](https://www.github.com/phpredis/phpredis/commit/a81b4f2d), - [95c8aab9](https://www.github.com/phpredis/phpredis/commit/95c8aab9), [235a27](https://www.github.com/phpredis/phpredis/commit/235a27) ([@michael-grunder](https://github.com/michael-grunder), [@yatsukhnenko](https://github.com/weltling)) -- Remove HAVE_SPL define [[55c5586c](https://www.github.com/phpredis/phpredis/commit/55c5586c)] ([@petk](https://github.com/petk)) +- Soft deprecate methods that aren't actually Valkey commands [a81b4f2d](https://www.github.com/valkey-php/valkey-php/commit/a81b4f2d), + [95c8aab9](https://www.github.com/valkey-php/valkey-php/commit/95c8aab9), [235a27](https://www.github.com/valkey-php/valkey-php/commit/235a27) ([@michael-grunder](https://github.com/michael-grunder), [@yatsukhnenko](https://github.com/weltling)) +- Remove HAVE_SPL define [[55c5586c](https://www.github.com/valkey-php/valkey-php/commit/55c5586c)] ([@petk](https://github.com/petk)) ### Removed -- Drop PHP5 support [[f9928642](https://www.github.com/phpredis/phpredis/commit/f9928642), [46a50c12](https://www.github.com/phpredis/phpredis/commit/46a50c12), [4601887d](https://www.github.com/phpredis/phpredis/commit/4601887d), [6ebb36ce](https://www.github.com/phpredis/phpredis/commit/6ebb36ce), [fdbe9d29](https://www.github.com/phpredis/phpredis/commit/fdbe9d29)] (Michael +- Drop PHP5 support [[f9928642](https://www.github.com/valkey-php/valkey-php/commit/f9928642), [46a50c12](https://www.github.com/valkey-php/valkey-php/commit/46a50c12), [4601887d](https://www.github.com/valkey-php/valkey-php/commit/4601887d), [6ebb36ce](https://www.github.com/valkey-php/valkey-php/commit/6ebb36ce), [fdbe9d29](https://www.github.com/valkey-php/valkey-php/commit/fdbe9d29)] (Michael Grunder) ### Fixed -- Reworked PHP msgpack >= 2.0.3 version requirement. [6973478](https://www.github.com/phpredis/phpredis/commit/6973478)..[a537df8](https://www.github.com/phpredis/phpredis/commit/a537df8) +- Reworked PHP msgpack >= 2.0.3 version requirement. [6973478](https://www.github.com/valkey-php/valkey-php/commit/6973478)..[a537df8](https://www.github.com/valkey-php/valkey-php/commit/a537df8) ([@michael-grunder](https://github.com/michael-grunder)). -- Enable pooling for cluster slave nodes [17600dd1](https://www.github.com/phpredis/phpredis/commit/17600dd1) ([Michael Grunder](https://github.com/michael-grunder)) -- xInfo response format [4852a510](https://www.github.com/phpredis/phpredis/commit/4852a510), [ac9dca0a](https://www.github.com/phpredis/phpredis/commit/ac9dca0a) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- Enable pooling for cluster slave nodes [17600dd1](https://www.github.com/valkey-php/valkey-php/commit/17600dd1) ([Michael Grunder](https://github.com/michael-grunder)) +- xInfo response format [4852a510](https://www.github.com/valkey-php/valkey-php/commit/4852a510), [ac9dca0a](https://www.github.com/valkey-php/valkey-php/commit/ac9dca0a) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Make the XREADGROUP optional COUNT and BLOCK arguments nullable - [0c17bd27](https://www.github.com/phpredis/phpredis/commit/0c17bd27) + [0c17bd27](https://www.github.com/valkey-php/valkey-php/commit/0c17bd27) ([Michael Grunder](https://github.com/michael-grunder)) -- Allow persistent_id to be passed as NULL with strict_types enabled [60223762](https://www.github.com/phpredis/phpredis/commit/60223762) +- Allow persistent_id to be passed as NULL with strict_types enabled [60223762](https://www.github.com/valkey-php/valkey-php/commit/60223762) ([Michael Grunder](https://github.com/michael-grunder)) -- Fix TypeError when using built-in constants in `setOption` [4c7643ee](https://www.github.com/phpredis/phpredis/commit/4c7643ee) +- Fix TypeError when using built-in constants in `setOption` [4c7643ee](https://www.github.com/valkey-php/valkey-php/commit/4c7643ee) ([@JoyceBabu](https://github.com/JoyceBabu)) -- Handle references in MGET [60d8b679](https://www.github.com/phpredis/phpredis/commit/60d8b679) ([Michael Grunder](https://github.com/michael-grunder)) +- Handle references in MGET [60d8b679](https://www.github.com/valkey-php/valkey-php/commit/60d8b679) ([Michael Grunder](https://github.com/michael-grunder)) --- -## [4.3.0] - 2019-03-13 ([GitHub](https://github.com/phpredis/phpredis/releases/tag/4.3.0), [PECL](https://pecl.php.net/package/redis/4.3.0)) +## [4.3.0] - 2019-03-13 ([GitHub](https://github.com/valkey-php/valkey-php/releases/tag/4.3.0), [PECL](https://pecl.php.net/package/redis/4.3.0)) This is probably the last release with PHP 5 support!!! ### Added -- RedisArray auth [b5549cff](https://www.github.com/phpredis/phpredis/commit/b5549cff), [339cfa2b](https://www.github.com/phpredis/phpredis/commit/339cfa2b), - [6b411aa8](https://www.github.com/phpredis/phpredis/commit/6b411aa8) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Add ZPOPMAX and ZPOPMIN support [46f03561](https://www.github.com/phpredis/phpredis/commit/46f03561), - [f89e941a](https://www.github.com/phpredis/phpredis/commit/f89e941a), - [2ec7d91a](https://www.github.com/phpredis/phpredis/commit/2ec7d91a) (@mbezhanov, [Michael Grunder](https://github.com/michael-grunder)) -- Implement GEORADIUS_RO and GEORADIUSBYMEMBER_RO [22d81a94](https://www.github.com/phpredis/phpredis/commit/22d81a94) ([Michael Grunder](https://github.com/michael-grunder)) -- RedisCluster auth [c5994f2a](https://www.github.com/phpredis/phpredis/commit/c5994f2a) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Different key hashing algorithms from hash extension [850027ff](https://www.github.com/phpredis/phpredis/commit/850027ff) +- ValkeyArray auth [b5549cff](https://www.github.com/valkey-php/valkey-php/commit/b5549cff), [339cfa2b](https://www.github.com/valkey-php/valkey-php/commit/339cfa2b), + [6b411aa8](https://www.github.com/valkey-php/valkey-php/commit/6b411aa8) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- Add ZPOPMAX and ZPOPMIN support [46f03561](https://www.github.com/valkey-php/valkey-php/commit/46f03561), + [f89e941a](https://www.github.com/valkey-php/valkey-php/commit/f89e941a), + [2ec7d91a](https://www.github.com/valkey-php/valkey-php/commit/2ec7d91a) (@mbezhanov, [Michael Grunder](https://github.com/michael-grunder)) +- Implement GEORADIUS_RO and GEORADIUSBYMEMBER_RO [22d81a94](https://www.github.com/valkey-php/valkey-php/commit/22d81a94) ([Michael Grunder](https://github.com/michael-grunder)) +- ValkeyCluster auth [c5994f2a](https://www.github.com/valkey-php/valkey-php/commit/c5994f2a) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- Different key hashing algorithms from hash extension [850027ff](https://www.github.com/valkey-php/valkey-php/commit/850027ff) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) ### Changed -- Proper persistent connections pooling implementation [a3703820](https://www.github.com/phpredis/phpredis/commit/a3703820), - [c76e00fb](https://www.github.com/phpredis/phpredis/commit/c76e00fb), [0433dc03](https://www.github.com/phpredis/phpredis/commit/0433dc03), - [c75b3b93](https://www.github.com/phpredis/phpredis/commit/c75b3b93) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Use zend_string for storing key hashing algorithm [8cd165df](https://www.github.com/phpredis/phpredis/commit/8cd165df), - [64e6a57f](https://www.github.com/phpredis/phpredis/commit/64e6a57f), [Pavlo Yatsukhnenko](https://github.com/yatsukhnenko) +- Proper persistent connections pooling implementation [a3703820](https://www.github.com/valkey-php/valkey-php/commit/a3703820), + [c76e00fb](https://www.github.com/valkey-php/valkey-php/commit/c76e00fb), [0433dc03](https://www.github.com/valkey-php/valkey-php/commit/0433dc03), + [c75b3b93](https://www.github.com/valkey-php/valkey-php/commit/c75b3b93) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- Use zend_string for storing key hashing algorithm [8cd165df](https://www.github.com/valkey-php/valkey-php/commit/8cd165df), + [64e6a57f](https://www.github.com/valkey-php/valkey-php/commit/64e6a57f), [Pavlo Yatsukhnenko](https://github.com/yatsukhnenko) -- Add callback parameter to subscribe/psubscribe arginfo [0653ff31](https://www.github.com/phpredis/phpredis/commit/0653ff31), +- Add callback parameter to subscribe/psubscribe arginfo [0653ff31](https://www.github.com/valkey-php/valkey-php/commit/0653ff31), ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Xgroup updates [15995c06](https://www.github.com/phpredis/phpredis/commit/15995c06) ([Michael Grunder](https://github.com/michael-grunder)) -- Use zend_string for pipeline_cmd [e98f5116](https://www.github.com/phpredis/phpredis/commit/e98f5116) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Implement consistent hashing algorithm for RedisArray [bb32e6f3](https://www.github.com/phpredis/phpredis/commit/bb32e6f3), [71922bf1](https://www.github.com/phpredis/phpredis/commit/71922bf1) +- Xgroup updates [15995c06](https://www.github.com/valkey-php/valkey-php/commit/15995c06) ([Michael Grunder](https://github.com/michael-grunder)) +- Use zend_string for pipeline_cmd [e98f5116](https://www.github.com/valkey-php/valkey-php/commit/e98f5116) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- Implement consistent hashing algorithm for ValkeyArray [bb32e6f3](https://www.github.com/valkey-php/valkey-php/commit/bb32e6f3), [71922bf1](https://www.github.com/valkey-php/valkey-php/commit/71922bf1) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Use zend_string for storing RedisArray hosts [602740d3](https://www.github.com/phpredis/phpredis/commit/602740d3), - [3e7e1c83](https://www.github.com/phpredis/phpredis/commit/3e7e1c83) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Refactor redis_sock_read_bulk_reply [bc4dbc4b](https://www.github.com/phpredis/phpredis/commit/bc4dbc4b) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- Use zend_string for storing ValkeyArray hosts [602740d3](https://www.github.com/valkey-php/valkey-php/commit/602740d3), + [3e7e1c83](https://www.github.com/valkey-php/valkey-php/commit/3e7e1c83) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- Refactor redis_sock_read_bulk_reply [bc4dbc4b](https://www.github.com/valkey-php/valkey-php/commit/bc4dbc4b) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) ### Fixed -- Don't check the number affected keys in PS_UPDATE_TIMESTAMP_FUNC [b00060ce](https://www.github.com/phpredis/phpredis/commit/b00060ce) +- Don't check the number affected keys in PS_UPDATE_TIMESTAMP_FUNC [b00060ce](https://www.github.com/valkey-php/valkey-php/commit/b00060ce) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Cancel pipeline mode without executing commands [789256d7](https://www.github.com/phpredis/phpredis/commit/789256d7) +- Cancel pipeline mode without executing commands [789256d7](https://www.github.com/valkey-php/valkey-php/commit/789256d7) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Breaking the lock acquire loop in case of network problems [61889cd7](https://www.github.com/phpredis/phpredis/commit/61889cd7) +- Breaking the lock acquire loop in case of network problems [61889cd7](https://www.github.com/valkey-php/valkey-php/commit/61889cd7) ([@SkydiveMarius](https://github.com/SkydiveMarius)) -- Update lzf_compress to be compatible with PECL lzf extension [b27fd430](https://www.github.com/phpredis/phpredis/commit/b27fd430) +- Update lzf_compress to be compatible with PECL lzf extension [b27fd430](https://www.github.com/valkey-php/valkey-php/commit/b27fd430) ([@jrchamp](https://github.com/jrchamp)) -- Fix RedisCluster keys memory leak [3b56b7db](https://www.github.com/phpredis/phpredis/commit/3b56b7db) ([Michael Grunder](https://github.com/michael-grunder)) -- Directly use return_value in RedisCluster::keys method [ad10a49e](https://www.github.com/phpredis/phpredis/commit/ad10a49e) +- Fix ValkeyCluster keys memory leak [3b56b7db](https://www.github.com/valkey-php/valkey-php/commit/3b56b7db) ([Michael Grunder](https://github.com/michael-grunder)) +- Directly use return_value in ValkeyCluster::keys method [ad10a49e](https://www.github.com/valkey-php/valkey-php/commit/ad10a49e) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Fix segfault in Redis Cluster with inconsistent configuration [72749916](https://www.github.com/phpredis/phpredis/commit/72749916), - [6e455e2e](https://www.github.com/phpredis/phpredis/commit/6e455e2e) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Masters info leakfix [91bd7426](https://www.github.com/phpredis/phpredis/commit/91bd7426) ([Michael Grunder](https://github.com/michael-grunder)) -- Remove unused parameter lazy_connect from redis_sock_create [c0793e8b](https://www.github.com/phpredis/phpredis/commit/c0793e8b) +- Fix segfault in Valkey Cluster with inconsistent configuration [72749916](https://www.github.com/valkey-php/valkey-php/commit/72749916), + [6e455e2e](https://www.github.com/valkey-php/valkey-php/commit/6e455e2e) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- Masters info leakfix [91bd7426](https://www.github.com/valkey-php/valkey-php/commit/91bd7426) ([Michael Grunder](https://github.com/michael-grunder)) +- Remove unused parameter lazy_connect from redis_sock_create [c0793e8b](https://www.github.com/valkey-php/valkey-php/commit/c0793e8b) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Remove useless `ZEND_ACC_[C|D]TOR`. [bc9b5597](https://www.github.com/phpredis/phpredis/commit/bc9b5597) (@[twosee](https://github.com/twose)) +- Remove useless `ZEND_ACC_[C|D]TOR`. [bc9b5597](https://www.github.com/valkey-php/valkey-php/commit/bc9b5597) (@[twosee](https://github.com/twose)) - Documentation improvements ([yulonghu](https://github.com/yulonghu), [@alexander-schranz](https://github.com/alexander-schranz), [@hmc](https://github.com/hmczju), [Pavlo Yatsukhnenko](https://github.com/yatsukhnenko), [Michael Grunder](https://github.com/michael-grunder)) --- -## [4.2.0] - 2018-11-08 ([GitHub](https://github.com/phpredis/phpredis/releases/tag/4.2.0), [PECL](https://pecl.php.net/package/redis/4.2.0)) +## [4.2.0] - 2018-11-08 ([GitHub](https://github.com/valkey-php/valkey-php/releases/tag/4.2.0), [PECL](https://pecl.php.net/package/redis/4.2.0)) The main feature of this release is new Streams API implemented by [Michael Grunder](https://github.com/michael-grunder). ### Added -- Streams API [2c9e0572](https://www.github.com/phpredis/phpredis/commit/2c9e0572), [0b97ec37](https://www.github.com/phpredis/phpredis/commit/0b97ec37) ([Michael Grunder](https://github.com/michael-grunder)) -- Display ini entries in output of phpinfo [908ac4b3](https://www.github.com/phpredis/phpredis/commit/908ac4b3) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- Streams API [2c9e0572](https://www.github.com/valkey-php/valkey-php/commit/2c9e0572), [0b97ec37](https://www.github.com/valkey-php/valkey-php/commit/0b97ec37) ([Michael Grunder](https://github.com/michael-grunder)) +- Display ini entries in output of phpinfo [908ac4b3](https://www.github.com/valkey-php/valkey-php/commit/908ac4b3) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Persistent connections can be closed via close method + change reconnection - logic [1d997873](https://www.github.com/phpredis/phpredis/commit/1d997873) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) + logic [1d997873](https://www.github.com/valkey-php/valkey-php/commit/1d997873) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) ### Changed -- Optimize close method [2a1ef961](https://www.github.com/phpredis/phpredis/commit/2a1ef961) ([yulonghu](https://github.com/yulonghu)) -- Use a ZSET instead of SET for EVAL tests [2e412373](https://www.github.com/phpredis/phpredis/commit/2e412373) ([Michael Grunder](https://github.com/michael-grunder)) -- Modify session testing logic [bfd27471](https://www.github.com/phpredis/phpredis/commit/bfd27471) ([Michael Grunder](https://github.com/michael-grunder)) +- Optimize close method [2a1ef961](https://www.github.com/valkey-php/valkey-php/commit/2a1ef961) ([yulonghu](https://github.com/yulonghu)) +- Use a ZSET instead of SET for EVAL tests [2e412373](https://www.github.com/valkey-php/valkey-php/commit/2e412373) ([Michael Grunder](https://github.com/michael-grunder)) +- Modify session testing logic [bfd27471](https://www.github.com/valkey-php/valkey-php/commit/bfd27471) ([Michael Grunder](https://github.com/michael-grunder)) - Documentation improvements ([@michael-grunder](https://github.com/michael-grunder), [@elcheco](https://github.com/elcheco), [@lucascourot](https://github.com/lucascourot), [@nolimitdev](https://github.com/nolimitdev), [Michael Grunder](https://github.com/michael-grunder)) ### Fixed -- Prevent potential infinite loop for sessions [4e2de158](https://www.github.com/phpredis/phpredis/commit/4e2de158) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Fix coverty warnings [6f7ddd27](https://www.github.com/phpredis/phpredis/commit/6f7ddd27) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Fix session memory leaks [071a1d54](https://www.github.com/phpredis/phpredis/commit/071a1d54), [92f14b14](https://www.github.com/phpredis/phpredis/commit/92f14b14) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko), +- Prevent potential infinite loop for sessions [4e2de158](https://www.github.com/valkey-php/valkey-php/commit/4e2de158) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- Fix coverty warnings [6f7ddd27](https://www.github.com/valkey-php/valkey-php/commit/6f7ddd27) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- Fix session memory leaks [071a1d54](https://www.github.com/valkey-php/valkey-php/commit/071a1d54), [92f14b14](https://www.github.com/valkey-php/valkey-php/commit/92f14b14) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko), [Michael Grunder](https://github.com/michael-grunder)) -- Fix XCLAIM on 32-bit installs [18dc2aac](https://www.github.com/phpredis/phpredis/commit/18dc2aac) ([Michael Grunder](https://github.com/michael-grunder)) -- Build warning fixes [b5093910](https://www.github.com/phpredis/phpredis/commit/b5093910), [51027044](https://www.github.com/phpredis/phpredis/commit/51027044), [8b0f28cd](https://www.github.com/phpredis/phpredis/commit/8b0f28cd) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko), +- Fix XCLAIM on 32-bit installs [18dc2aac](https://www.github.com/valkey-php/valkey-php/commit/18dc2aac) ([Michael Grunder](https://github.com/michael-grunder)) +- Build warning fixes [b5093910](https://www.github.com/valkey-php/valkey-php/commit/b5093910), [51027044](https://www.github.com/valkey-php/valkey-php/commit/51027044), [8b0f28cd](https://www.github.com/valkey-php/valkey-php/commit/8b0f28cd) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko), [Remi Collet](https://github.com/remicollet), [twosee](https://github.com/twose)) -- Fix incorrect arginfo for `Redis::sRem` and `Redis::multi` [25b043ce](https://www.github.com/phpredis/phpredis/commit/25b043ce) +- Fix incorrect arginfo for `Valkey::sRem` and `Valkey::multi` [25b043ce](https://www.github.com/valkey-php/valkey-php/commit/25b043ce) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Treat a -1 response from cluster_check_response as a timeout. [27df9220](https://www.github.com/phpredis/phpredis/commit/27df9220), - [07ef7f4e](https://www.github.com/phpredis/phpredis/commit/07ef7f4e), [d1172426](https://www.github.com/phpredis/phpredis/commit/d1172426) ([Michael Grunder](https://github.com/michael-grunder)). -- Missing space between command and args [0af2a7fe](https://www.github.com/phpredis/phpredis/commit/0af2a7fe) ([@remicollet](https://github.com/remicollet)) +- Treat a -1 response from cluster_check_response as a timeout. [27df9220](https://www.github.com/valkey-php/valkey-php/commit/27df9220), + [07ef7f4e](https://www.github.com/valkey-php/valkey-php/commit/07ef7f4e), [d1172426](https://www.github.com/valkey-php/valkey-php/commit/d1172426) ([Michael Grunder](https://github.com/michael-grunder)). +- Missing space between command and args [0af2a7fe](https://www.github.com/valkey-php/valkey-php/commit/0af2a7fe) ([@remicollet](https://github.com/remicollet)) - Reset the socket after a timeout to make sure no wrong data is received - [cd6ebc6d](https://www.github.com/phpredis/phpredis/commit/cd6ebc6d) ([@marcdejonge](https://github.com/marcdejonge)) + [cd6ebc6d](https://www.github.com/valkey-php/valkey-php/commit/cd6ebc6d) ([@marcdejonge](https://github.com/marcdejonge)) - Allow '-' and '+' arguments and add tests for zLexCount and zRemRangeByLex - [d4a08697](https://www.github.com/phpredis/phpredis/commit/d4a08697) ([Michael Grunder](https://github.com/michael-grunder)) -- Fix printf format warnings [dcde9331](https://www.github.com/phpredis/phpredis/commit/dcde9331) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Session module is required [58bd8cc8](https://www.github.com/phpredis/phpredis/commit/58bd8cc8) ([@remicollet](https://github.com/remicollet)) -- Set default values for ini entries [e206ce9c](https://www.github.com/phpredis/phpredis/commit/e206ce9c) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) + [d4a08697](https://www.github.com/valkey-php/valkey-php/commit/d4a08697) ([Michael Grunder](https://github.com/michael-grunder)) +- Fix printf format warnings [dcde9331](https://www.github.com/valkey-php/valkey-php/commit/dcde9331) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- Session module is required [58bd8cc8](https://www.github.com/valkey-php/valkey-php/commit/58bd8cc8) ([@remicollet](https://github.com/remicollet)) +- Set default values for ini entries [e206ce9c](https://www.github.com/valkey-php/valkey-php/commit/e206ce9c) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) --- -## [4.0.0] - 2018-03-07 ([GitHub](https://github.com/phpredis/phpredis/releases/tag/4.0.0), [PECL](https://pecl.php.net/package/redis/4.0.0)) +## [4.0.0] - 2018-03-07 ([GitHub](https://github.com/valkey-php/valkey-php/releases/tag/4.0.0), [PECL](https://pecl.php.net/package/redis/4.0.0)) *WARNING:* THIS RELEASE CONTAINS BREAKING API CHANGES! ### Added - Add proper ARGINFO for all methods. ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko), [Michael Grunder](https://github.com/michael-grunder)) -- Let EXISTS take multiple keys [cccc39](https://www.github.com/phpredis/phpredis/commit/cccc39) ([Michael Grunder](https://github.com/michael-grunder)) -- Implement SWAPDB and UNLINK commands [84f1f28b](https://www.github.com/phpredis/phpredis/commit/84f1f28b), [9e65c429](https://www.github.com/phpredis/phpredis/commit/9e65c429) ([Michael Grunder](https://github.com/michael-grunder)) -- Add LZF compression (experimental) [e2c51251](https://www.github.com/phpredis/phpredis/commit/e2c51251), [8cb2d5bd](https://www.github.com/phpredis/phpredis/commit/8cb2d5bd), [8657557](https://www.github.com/phpredis/phpredis/commit/8657557) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Allow mixing MULTI and PIPELINE modes (experimental) [5874b0](https://www.github.com/phpredis/phpredis/commit/5874b0) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- Let EXISTS take multiple keys [cccc39](https://www.github.com/valkey-php/valkey-php/commit/cccc39) ([Michael Grunder](https://github.com/michael-grunder)) +- Implement SWAPDB and UNLINK commands [84f1f28b](https://www.github.com/valkey-php/valkey-php/commit/84f1f28b), [9e65c429](https://www.github.com/valkey-php/valkey-php/commit/9e65c429) ([Michael Grunder](https://github.com/michael-grunder)) +- Add LZF compression (experimental) [e2c51251](https://www.github.com/valkey-php/valkey-php/commit/e2c51251), [8cb2d5bd](https://www.github.com/valkey-php/valkey-php/commit/8cb2d5bd), [8657557](https://www.github.com/valkey-php/valkey-php/commit/8657557) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- Allow mixing MULTI and PIPELINE modes (experimental) [5874b0](https://www.github.com/valkey-php/valkey-php/commit/5874b0) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) ### Changed - Use zend_string as returning value for ra_extract_key and ra_call_extractor - [9cd05911](https://www.github.com/phpredis/phpredis/commit/9cd05911) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Return real connection error as exception [5b9c0c60](https://www.github.com/phpredis/phpredis/commit/5b9c0c60) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko), + [9cd05911](https://www.github.com/valkey-php/valkey-php/commit/9cd05911) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- Return real connection error as exception [5b9c0c60](https://www.github.com/valkey-php/valkey-php/commit/5b9c0c60) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko), [Michael Grunder](https://github.com/michael-grunder)) -- Use zend_string for storing auth and prefix members [4b8336f7](https://www.github.com/phpredis/phpredis/commit/4b8336f7) +- Use zend_string for storing auth and prefix members [4b8336f7](https://www.github.com/valkey-php/valkey-php/commit/4b8336f7) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Add tcp_keepalive option to redis sock [68c58513](https://www.github.com/phpredis/phpredis/commit/68c58513), [5101172a](https://www.github.com/phpredis/phpredis/commit/5101172a), [010336d5](https://www.github.com/phpredis/phpredis/commit/010336d5), - [51e48729](https://www.github.com/phpredis/phpredis/commit/51e48729) ([@git-hulk](https://github.com/git-hulk), [Michael Grunder](https://github.com/michael-grunder)) -- More robust GEORADIUS COUNT validation [f7edee5d](https://www.github.com/phpredis/phpredis/commit/f7edee5d) ([Michael Grunder](https://github.com/michael-grunder)) -- Allow to use empty string as persistent_id [ec4fd1bd](https://www.github.com/phpredis/phpredis/commit/ec4fd1bd) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- Add tcp_keepalive option to redis sock [68c58513](https://www.github.com/valkey-php/valkey-php/commit/68c58513), [5101172a](https://www.github.com/valkey-php/valkey-php/commit/5101172a), [010336d5](https://www.github.com/valkey-php/valkey-php/commit/010336d5), + [51e48729](https://www.github.com/valkey-php/valkey-php/commit/51e48729) ([@git-hulk](https://github.com/git-hulk), [Michael Grunder](https://github.com/michael-grunder)) +- More robust GEORADIUS COUNT validation [f7edee5d](https://www.github.com/valkey-php/valkey-php/commit/f7edee5d) ([Michael Grunder](https://github.com/michael-grunder)) +- Allow to use empty string as persistent_id [ec4fd1bd](https://www.github.com/valkey-php/valkey-php/commit/ec4fd1bd) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Documentation improvements ([Michael Grunder](https://github.com/michael-grunder), [@TomA-R](https://github.com/TomA-R)) ### Fixed -- Disallow using empty string as session name. [485db46f](https://www.github.com/phpredis/phpredis/commit/485db46f) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- The element of z_seeds may be a reference on php7 [367bc6aa](https://www.github.com/phpredis/phpredis/commit/367bc6aa), [1e63717a](https://www.github.com/phpredis/phpredis/commit/1e63717a) +- Disallow using empty string as session name. [485db46f](https://www.github.com/valkey-php/valkey-php/commit/485db46f) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- The element of z_seeds may be a reference on php7 [367bc6aa](https://www.github.com/valkey-php/valkey-php/commit/367bc6aa), [1e63717a](https://www.github.com/valkey-php/valkey-php/commit/1e63717a) ([@janic716](https://github.com/janic716)) -- Avoid connection in helper methods [91e9cfe1](https://www.github.com/phpredis/phpredis/commit/91e9cfe1) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Don't use convert_to_string in redis_hmget_cmd [99335d6](https://www.github.com/phpredis/phpredis/commit/99335d6) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- PHP >=7.3.0 uses zend_string to store `php_url` elements [b566fb44](https://www.github.com/phpredis/phpredis/commit/b566fb44) ([@fmk](https://github.com/fmk)) +- Avoid connection in helper methods [91e9cfe1](https://www.github.com/valkey-php/valkey-php/commit/91e9cfe1) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- Don't use convert_to_string in redis_hmget_cmd [99335d6](https://www.github.com/valkey-php/valkey-php/commit/99335d6) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- PHP >=7.3.0 uses zend_string to store `php_url` elements [b566fb44](https://www.github.com/valkey-php/valkey-php/commit/b566fb44) ([@fmk](https://github.com/fmk)) --- -## [3.1.5] - 2017-09-27 ([GitHub](https://github.com/phpredis/phpredis/releases/tag/3.1.5), [PECL](https://pecl.php.net/package/redis/3.1.5)) +## [3.1.5] - 2017-09-27 ([GitHub](https://github.com/valkey-php/valkey-php/releases/tag/3.1.5), [PECL](https://pecl.php.net/package/redis/3.1.5)) This is interim release which contains only bug fixes. ### Fixed -- Fix segfault when extending Redis class in PHP 5 [d23eff](https://www.github.com/phpredis/phpredis/commit/d23eff) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Fix RedisCluster constructor with PHP 7 strict scalar type [5c21d7](https://www.github.com/phpredis/phpredis/commit/5c21d7) +- Fix segfault when extending Valkey class in PHP 5 [d23eff](https://www.github.com/valkey-php/valkey-php/commit/d23eff) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- Fix ValkeyCluster constructor with PHP 7 strict scalar type [5c21d7](https://www.github.com/valkey-php/valkey-php/commit/5c21d7) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Allow to use empty string as persistent_id [344de5](https://www.github.com/phpredis/phpredis/commit/344de5) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Fix cluster_init_seeds. [db1347](https://www.github.com/phpredis/phpredis/commit/db1347) ([@adlagares](https://github.com/adlagares)) -- Fix z_seeds may be a reference [42581a](https://www.github.com/phpredis/phpredis/commit/42581a) ([@janic716](https://github.com/janic716)) -- PHP >=7.3 uses zend_string for php_url elements [b566fb](https://www.github.com/phpredis/phpredis/commit/b566fb) ([@fmk](https://github.com/fmk)) +- Allow to use empty string as persistent_id [344de5](https://www.github.com/valkey-php/valkey-php/commit/344de5) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- Fix cluster_init_seeds. [db1347](https://www.github.com/valkey-php/valkey-php/commit/db1347) ([@adlagares](https://github.com/adlagares)) +- Fix z_seeds may be a reference [42581a](https://www.github.com/valkey-php/valkey-php/commit/42581a) ([@janic716](https://github.com/janic716)) +- PHP >=7.3 uses zend_string for php_url elements [b566fb](https://www.github.com/valkey-php/valkey-php/commit/b566fb) ([@fmk](https://github.com/fmk)) --- -## [3.1.4] - 2017-09-27 ([GitHub](https://github.com/phpredis/phpredis/releases/tag/3.1.4), [PECL](https://pecl.php.net/package/redis/3.1.4)) +## [3.1.4] - 2017-09-27 ([GitHub](https://github.com/valkey-php/valkey-php/releases/tag/3.1.4), [PECL](https://pecl.php.net/package/redis/3.1.4)) -The primary new feature phpredis 3.1.4 is the ability to send MULTI .. EXEC +The primary new feature valkey-php 3.1.4 is the ability to send MULTI .. EXEC blocks in pipeline mode. There are also many bugfixes and minor improvements to the api, listed below. ### Added -- Allow mixing MULTI and PIPELINE modes (experimental)! [5874b0](https://www.github.com/phpredis/phpredis/commit/5874b0) +- Allow mixing MULTI and PIPELINE modes (experimental)! [5874b0](https://www.github.com/valkey-php/valkey-php/commit/5874b0) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Added integration for coverty static analysis and fixed several warnings - [faac8b0](https://www.github.com/phpredis/phpredis/commit/faac8b0), [eff7398](https://www.github.com/phpredis/phpredis/commit/eff7398), [4766c25](https://www.github.com/phpredis/phpredis/commit/4766c25), [0438ab4](https://www.github.com/phpredis/phpredis/commit/0438ab4), [1e0b065](https://www.github.com/phpredis/phpredis/commit/1e0b065), [733732a](https://www.github.com/phpredis/phpredis/commit/733732a), [26eeda5](https://www.github.com/phpredis/phpredis/commit/26eeda5), [735025](https://www.github.com/phpredis/phpredis/commit/735025), - [42f1c9](https://www.github.com/phpredis/phpredis/commit/42f1c9), [af71d4](https://www.github.com/phpredis/phpredis/commit/af71d4) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)). -- Added arginfo introspection structures [81a0303](https://www.github.com/phpredis/phpredis/commit/81a0303), [d5609fc](https://www.github.com/phpredis/phpredis/commit/d5609fc), [e5660be](https://www.github.com/phpredis/phpredis/commit/e5660be), [3c60e1f](https://www.github.com/phpredis/phpredis/commit/3c60e1f), - [50dcb15](https://www.github.com/phpredis/phpredis/commit/50dcb15), [6c2c6fa](https://www.github.com/phpredis/phpredis/commit/6c2c6fa), [212e323](https://www.github.com/phpredis/phpredis/commit/212e323), [e23be2c](https://www.github.com/phpredis/phpredis/commit/e23be2c), [682593d](https://www.github.com/phpredis/phpredis/commit/682593d), [f8de702](https://www.github.com/phpredis/phpredis/commit/f8de702), [4ef3acd](https://www.github.com/phpredis/phpredis/commit/4ef3acd), [f116be9](https://www.github.com/phpredis/phpredis/commit/f116be9), - [5c111dd](https://www.github.com/phpredis/phpredis/commit/5c111dd), [9caa029](https://www.github.com/phpredis/phpredis/commit/9caa029), [0d69650](https://www.github.com/phpredis/phpredis/commit/0d69650), [6859828](https://www.github.com/phpredis/phpredis/commit/6859828), [024e593](https://www.github.com/phpredis/phpredis/commit/024e593), [3643ab6](https://www.github.com/phpredis/phpredis/commit/3643ab6), [f576fab](https://www.github.com/phpredis/phpredis/commit/f576fab), [122d41f](https://www.github.com/phpredis/phpredis/commit/122d41f), - [a09d0e6](https://www.github.com/phpredis/phpredis/commit/a09d0e6) ([Tyson Andre](https://github.com/TysonAndre), [Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)). -- Added a github issue template [61aba9](https://www.github.com/phpredis/phpredis/commit/61aba9) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) + [faac8b0](https://www.github.com/valkey-php/valkey-php/commit/faac8b0), [eff7398](https://www.github.com/valkey-php/valkey-php/commit/eff7398), [4766c25](https://www.github.com/valkey-php/valkey-php/commit/4766c25), [0438ab4](https://www.github.com/valkey-php/valkey-php/commit/0438ab4), [1e0b065](https://www.github.com/valkey-php/valkey-php/commit/1e0b065), [733732a](https://www.github.com/valkey-php/valkey-php/commit/733732a), [26eeda5](https://www.github.com/valkey-php/valkey-php/commit/26eeda5), [735025](https://www.github.com/valkey-php/valkey-php/commit/735025), + [42f1c9](https://www.github.com/valkey-php/valkey-php/commit/42f1c9), [af71d4](https://www.github.com/valkey-php/valkey-php/commit/af71d4) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)). +- Added arginfo introspection structures [81a0303](https://www.github.com/valkey-php/valkey-php/commit/81a0303), [d5609fc](https://www.github.com/valkey-php/valkey-php/commit/d5609fc), [e5660be](https://www.github.com/valkey-php/valkey-php/commit/e5660be), [3c60e1f](https://www.github.com/valkey-php/valkey-php/commit/3c60e1f), + [50dcb15](https://www.github.com/valkey-php/valkey-php/commit/50dcb15), [6c2c6fa](https://www.github.com/valkey-php/valkey-php/commit/6c2c6fa), [212e323](https://www.github.com/valkey-php/valkey-php/commit/212e323), [e23be2c](https://www.github.com/valkey-php/valkey-php/commit/e23be2c), [682593d](https://www.github.com/valkey-php/valkey-php/commit/682593d), [f8de702](https://www.github.com/valkey-php/valkey-php/commit/f8de702), [4ef3acd](https://www.github.com/valkey-php/valkey-php/commit/4ef3acd), [f116be9](https://www.github.com/valkey-php/valkey-php/commit/f116be9), + [5c111dd](https://www.github.com/valkey-php/valkey-php/commit/5c111dd), [9caa029](https://www.github.com/valkey-php/valkey-php/commit/9caa029), [0d69650](https://www.github.com/valkey-php/valkey-php/commit/0d69650), [6859828](https://www.github.com/valkey-php/valkey-php/commit/6859828), [024e593](https://www.github.com/valkey-php/valkey-php/commit/024e593), [3643ab6](https://www.github.com/valkey-php/valkey-php/commit/3643ab6), [f576fab](https://www.github.com/valkey-php/valkey-php/commit/f576fab), [122d41f](https://www.github.com/valkey-php/valkey-php/commit/122d41f), + [a09d0e6](https://www.github.com/valkey-php/valkey-php/commit/a09d0e6) ([Tyson Andre](https://github.com/TysonAndre), [Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)). +- Added a github issue template [61aba9](https://www.github.com/valkey-php/valkey-php/commit/61aba9) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) ### Changed -- Refactor redis_send_discard [ea15ce](https://www.github.com/phpredis/phpredis/commit/ea15ce) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Improve redis array rehash [577a91](https://www.github.com/phpredis/phpredis/commit/577a91) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Change redis array pure_cmds from zval to hashtable [a56ed7](https://www.github.com/phpredis/phpredis/commit/a56ed7) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- Refactor redis_send_discard [ea15ce](https://www.github.com/valkey-php/valkey-php/commit/ea15ce) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- Improve redis array rehash [577a91](https://www.github.com/valkey-php/valkey-php/commit/577a91) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- Change redis array pure_cmds from zval to hashtable [a56ed7](https://www.github.com/valkey-php/valkey-php/commit/a56ed7) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Use zend_string rather than char for various context fields (err, prefix, etc) - [2bf7b2](https://www.github.com/phpredis/phpredis/commit/2bf7b2) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Updated runtime exception handling [8dcaa4](https://www.github.com/phpredis/phpredis/commit/8dcaa4), [7c1407](https://www.github.com/phpredis/phpredis/commit/7c1407) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) + [2bf7b2](https://www.github.com/valkey-php/valkey-php/commit/2bf7b2) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- Updated runtime exception handling [8dcaa4](https://www.github.com/valkey-php/valkey-php/commit/8dcaa4), [7c1407](https://www.github.com/valkey-php/valkey-php/commit/7c1407) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) ### Fixed -- Fixed link to redis cluster documentation [3b0b06](https://www.github.com/phpredis/phpredis/commit/3b0b06) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Removed duplicate HGET in redis array hash table, formatting [d0b9c5](https://www.github.com/phpredis/phpredis/commit/d0b9c5) +- Fixed link to redis cluster documentation [3b0b06](https://www.github.com/valkey-php/valkey-php/commit/3b0b06) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- Removed duplicate HGET in redis array hash table, formatting [d0b9c5](https://www.github.com/valkey-php/valkey-php/commit/d0b9c5) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)). -- Treat NULL bulk as success for session read [659450](https://www.github.com/phpredis/phpredis/commit/659450) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Fix valgrind warnings [471ce07](https://www.github.com/phpredis/phpredis/commit/471ce07), [1ab89e1](https://www.github.com/phpredis/phpredis/commit/1ab89e1), [b624a8b](https://www.github.com/phpredis/phpredis/commit/b624a8b) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Fix php5/php7 compatibility layer [1ab89e](https://www.github.com/phpredis/phpredis/commit/1ab89e), [4e3225](https://www.github.com/phpredis/phpredis/commit/4e3225) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Fix typo in README.markdown [e47e44](https://www.github.com/phpredis/phpredis/commit/e47e44) ([Toby Schrapel](https://github.com/schrapel)) -- Initialize gc member of zend_string [37f569](https://www.github.com/phpredis/phpredis/commit/37f569) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)). +- Treat NULL bulk as success for session read [659450](https://www.github.com/valkey-php/valkey-php/commit/659450) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- Fix valgrind warnings [471ce07](https://www.github.com/valkey-php/valkey-php/commit/471ce07), [1ab89e1](https://www.github.com/valkey-php/valkey-php/commit/1ab89e1), [b624a8b](https://www.github.com/valkey-php/valkey-php/commit/b624a8b) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- Fix php5/php7 compatibility layer [1ab89e](https://www.github.com/valkey-php/valkey-php/commit/1ab89e), [4e3225](https://www.github.com/valkey-php/valkey-php/commit/4e3225) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- Fix typo in README.markdown [e47e44](https://www.github.com/valkey-php/valkey-php/commit/e47e44) ([Toby Schrapel](https://github.com/schrapel)) +- Initialize gc member of zend_string [37f569](https://www.github.com/valkey-php/valkey-php/commit/37f569) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)). - Don't try to set TCP_NODELAY on a unix socket and don't warn on multiple - calls to pipeline [d11798](https://www.github.com/phpredis/phpredis/commit/d11798), [77aeba](https://www.github.com/phpredis/phpredis/commit/77aeba) ([Michael Grunder](https://github.com/michael-grunder)) -- Various other library fixes [142b51](https://www.github.com/phpredis/phpredis/commit/142b51), [4452f6](https://www.github.com/phpredis/phpredis/commit/4452f6), [e672f4](https://www.github.com/phpredis/phpredis/commit/e672f4), [658ee3](https://www.github.com/phpredis/phpredis/commit/658ee3), [c9df77](https://www.github.com/phpredis/phpredis/commit/c9df77), [4a0a46](https://www.github.com/phpredis/phpredis/commit/4a0a46) + calls to pipeline [d11798](https://www.github.com/valkey-php/valkey-php/commit/d11798), [77aeba](https://www.github.com/valkey-php/valkey-php/commit/77aeba) ([Michael Grunder](https://github.com/michael-grunder)) +- Various other library fixes [142b51](https://www.github.com/valkey-php/valkey-php/commit/142b51), [4452f6](https://www.github.com/valkey-php/valkey-php/commit/4452f6), [e672f4](https://www.github.com/valkey-php/valkey-php/commit/e672f4), [658ee3](https://www.github.com/valkey-php/valkey-php/commit/658ee3), [c9df77](https://www.github.com/valkey-php/valkey-php/commit/c9df77), [4a0a46](https://www.github.com/valkey-php/valkey-php/commit/4a0a46) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) ### Removed -- Remove unused PHP_RINIT and PHP_RSHUTDOWN functions [c760bf](https://www.github.com/phpredis/phpredis/commit/c760bf) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- Remove unused PHP_RINIT and PHP_RSHUTDOWN functions [c760bf](https://www.github.com/valkey-php/valkey-php/commit/c760bf) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) --- -## [3.1.3] - 2017-07-15 ([GitHub](https://github.com/phpredis/phpredis/releases/tag/3.1.3), [PECL](https://pecl.php.net/package/redis/3.1.3)) +## [3.1.3] - 2017-07-15 ([GitHub](https://github.com/valkey-php/valkey-php/releases/tag/3.1.3), [PECL](https://pecl.php.net/package/redis/3.1.3)) This release contains two big improvements: 1. Adding a new printf like command construction function with additionally - format specifiers specific to phpredis. -2. Implementation of custom objects for Redis and RedisArray which eliminates + format specifiers specific to valkey-php. +2. Implementation of custom objects for Valkey and ValkeyArray which eliminates double hash lookup. Also many small improvements and bug fixes were made. ### Added -- Add hStrLen command [c52077](https://www.github.com/phpredis/phpredis/commit/c52077), [fb88e1](https://www.github.com/phpredis/phpredis/commit/fb88e1) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- A printf like method to construct a Redis RESP command [a4a0ed](https://www.github.com/phpredis/phpredis/commit/a4a0ed), [d75081](https://www.github.com/phpredis/phpredis/commit/d75081), - [bdd287](https://www.github.com/phpredis/phpredis/commit/bdd287), [0eaeae](https://www.github.com/phpredis/phpredis/commit/0eaeae), [b3d00d](https://www.github.com/phpredis/phpredis/commit/b3d00d) ([Michael Grunder](https://github.com/michael-grunder)) -- Use custom objects instead of zend_list for storing Redis/RedisArray [a765f8](https://www.github.com/phpredis/phpredis/commit/a765f8), - [8fa85a](https://www.github.com/phpredis/phpredis/commit/8fa85a) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Add configureoption tag to package.xml [750963](https://www.github.com/phpredis/phpredis/commit/750963) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- Add hStrLen command [c52077](https://www.github.com/valkey-php/valkey-php/commit/c52077), [fb88e1](https://www.github.com/valkey-php/valkey-php/commit/fb88e1) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- A printf like method to construct a Valkey RESP command [a4a0ed](https://www.github.com/valkey-php/valkey-php/commit/a4a0ed), [d75081](https://www.github.com/valkey-php/valkey-php/commit/d75081), + [bdd287](https://www.github.com/valkey-php/valkey-php/commit/bdd287), [0eaeae](https://www.github.com/valkey-php/valkey-php/commit/0eaeae), [b3d00d](https://www.github.com/valkey-php/valkey-php/commit/b3d00d) ([Michael Grunder](https://github.com/michael-grunder)) +- Use custom objects instead of zend_list for storing Valkey/ValkeyArray [a765f8](https://www.github.com/valkey-php/valkey-php/commit/a765f8), + [8fa85a](https://www.github.com/valkey-php/valkey-php/commit/8fa85a) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- Add configureoption tag to package.xml [750963](https://www.github.com/valkey-php/valkey-php/commit/750963) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) ### Changed -- Add optional COUNT argument to sPop [d2e203](https://www.github.com/phpredis/phpredis/commit/d2e203) ([Michael Grunder](https://github.com/michael-grunder)) -- Allow sInterStore to take one arg [26aec4](https://www.github.com/phpredis/phpredis/commit/26aec4), [4cd06b](https://www.github.com/phpredis/phpredis/commit/4cd06b) ([Michael Grunder](https://github.com/michael-grunder)) -- Allow MIGRATE to accept multiple keys [9aa3db](https://www.github.com/phpredis/phpredis/commit/9aa3db) ([Michael Grunder](https://github.com/michael-grunder)) -- Use crc32 table from PHP distro [f81694](https://www.github.com/phpredis/phpredis/commit/f81694) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Throw exception for all non recoverable errors [e37239](https://www.github.com/phpredis/phpredis/commit/e37239) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Increase read buffers size [520e06](https://www.github.com/phpredis/phpredis/commit/520e06) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Better documentation [f0c25a](https://www.github.com/phpredis/phpredis/commit/f0c25a), [c5991f](https://www.github.com/phpredis/phpredis/commit/c5991f), [9ec9ae](https://www.github.com/phpredis/phpredis/commit/9ec9ae) ([Michael Grunder](https://github.com/michael-grunder)) -- Better TravisCI integration [e37c08](https://www.github.com/phpredis/phpredis/commit/e37c08) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- Add optional COUNT argument to sPop [d2e203](https://www.github.com/valkey-php/valkey-php/commit/d2e203) ([Michael Grunder](https://github.com/michael-grunder)) +- Allow sInterStore to take one arg [26aec4](https://www.github.com/valkey-php/valkey-php/commit/26aec4), [4cd06b](https://www.github.com/valkey-php/valkey-php/commit/4cd06b) ([Michael Grunder](https://github.com/michael-grunder)) +- Allow MIGRATE to accept multiple keys [9aa3db](https://www.github.com/valkey-php/valkey-php/commit/9aa3db) ([Michael Grunder](https://github.com/michael-grunder)) +- Use crc32 table from PHP distro [f81694](https://www.github.com/valkey-php/valkey-php/commit/f81694) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- Throw exception for all non recoverable errors [e37239](https://www.github.com/valkey-php/valkey-php/commit/e37239) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- Increase read buffers size [520e06](https://www.github.com/valkey-php/valkey-php/commit/520e06) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- Better documentation [f0c25a](https://www.github.com/valkey-php/valkey-php/commit/f0c25a), [c5991f](https://www.github.com/valkey-php/valkey-php/commit/c5991f), [9ec9ae](https://www.github.com/valkey-php/valkey-php/commit/9ec9ae) ([Michael Grunder](https://github.com/michael-grunder)) +- Better TravisCI integration [e37c08](https://www.github.com/valkey-php/valkey-php/commit/e37c08) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) ### Fixed -- Make sure redisCluster members are all initialized on (re)creation [162d88](https://www.github.com/phpredis/phpredis/commit/162d88) +- Make sure redisCluster members are all initialized on (re)creation [162d88](https://www.github.com/valkey-php/valkey-php/commit/162d88) - ([Michael Grunder](https://github.com/michael-grunder)). -- Fix Null Bulk String response parsing in cluster library [058753](https://www.github.com/phpredis/phpredis/commit/058753) +- Fix Null Bulk String response parsing in cluster library [058753](https://www.github.com/valkey-php/valkey-php/commit/058753) - ([Alberto Fernández](https://github.com/albertofem)) -- Allow using numeric string in zInter command [ba0070](https://www.github.com/phpredis/phpredis/commit/ba0070) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Use ZVAL_DEREF macros for dereference input variables [ad4596](https://www.github.com/phpredis/phpredis/commit/ad4596) +- Allow using numeric string in zInter command [ba0070](https://www.github.com/valkey-php/valkey-php/commit/ba0070) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- Use ZVAL_DEREF macros for dereference input variables [ad4596](https://www.github.com/valkey-php/valkey-php/commit/ad4596) - ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Fix read_timeout [18149e](https://www.github.com/phpredis/phpredis/commit/18149e), [b56dc4](https://www.github.com/phpredis/phpredis/commit/b56dc4) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Fix zval_get_string impl for PHP5 [4e56ba](https://www.github.com/phpredis/phpredis/commit/4e56ba) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Fix Redis/RedisArray segfaults [be5c1f](https://www.github.com/phpredis/phpredis/commit/be5c1f), [635c3a](https://www.github.com/phpredis/phpredis/commit/635c3a), [1f8dde](https://www.github.com/phpredis/phpredis/commit/1f8dde), [43e1e0](https://www.github.com/phpredis/phpredis/commit/43e1e0) +- Fix read_timeout [18149e](https://www.github.com/valkey-php/valkey-php/commit/18149e), [b56dc4](https://www.github.com/valkey-php/valkey-php/commit/b56dc4) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- Fix zval_get_string impl for PHP5 [4e56ba](https://www.github.com/valkey-php/valkey-php/commit/4e56ba) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- Fix Valkey/ValkeyArray segfaults [be5c1f](https://www.github.com/valkey-php/valkey-php/commit/be5c1f), [635c3a](https://www.github.com/valkey-php/valkey-php/commit/635c3a), [1f8dde](https://www.github.com/valkey-php/valkey-php/commit/1f8dde), [43e1e0](https://www.github.com/valkey-php/valkey-php/commit/43e1e0) - ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Fix memory leak and potential segfault [aa6ff77a](https://www.github.com/phpredis/phpredis/commit/aa6ff77a), [88efaa](https://www.github.com/phpredis/phpredis/commit/88efaa) ([Michael Grunder](https://github.com/michael-grunder)) -- Assume "NULL bulk" reply as success (empty session data) [4a81e1](https://www.github.com/phpredis/phpredis/commit/4a81e1) +- Fix memory leak and potential segfault [aa6ff77a](https://www.github.com/valkey-php/valkey-php/commit/aa6ff77a), [88efaa](https://www.github.com/valkey-php/valkey-php/commit/88efaa) ([Michael Grunder](https://github.com/michael-grunder)) +- Assume "NULL bulk" reply as success (empty session data) [4a81e1](https://www.github.com/valkey-php/valkey-php/commit/4a81e1) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) - Refactoring ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko), [Michael Grunder](https://github.com/michael-grunder)) --- -## [3.1.2] - 2017-03-16 ([GitHub](https://github.com/phpredis/phpredis/releases/tag/3.1.2), [PECL](https://pecl.php.net/package/redis/3.1.2)) +## [3.1.2] - 2017-03-16 ([GitHub](https://github.com/valkey-php/valkey-php/releases/tag/3.1.2), [PECL](https://pecl.php.net/package/redis/3.1.2)) ### Changes -- Re allow single array for sInterStore [6ef0c2](https://www.github.com/phpredis/phpredis/commit/6ef0c2), [d01966](https://www.github.com/phpredis/phpredis/commit/d01966) ([Michael Grunder](https://github.com/michael-grunder)) -- Better TravisCI integration [4fd2f6](https://www.github.com/phpredis/phpredis/commit/4fd2f6) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- Re allow single array for sInterStore [6ef0c2](https://www.github.com/valkey-php/valkey-php/commit/6ef0c2), [d01966](https://www.github.com/valkey-php/valkey-php/commit/d01966) ([Michael Grunder](https://github.com/michael-grunder)) +- Better TravisCI integration [4fd2f6](https://www.github.com/valkey-php/valkey-php/commit/4fd2f6) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) ### Fixed -- RedisArray segfault fix [564ce3](https://www.github.com/phpredis/phpredis/commit/564ce3) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) -- Small memory leak fix [645888b](https://www.github.com/phpredis/phpredis/commit/645888b) (Mike Grunder) -- Segfault fix when recreating RedisCluster objects [abf7d4](https://www.github.com/phpredis/phpredis/commit/abf7d4) ([Michael Grunder](https://github.com/michael-grunder)) -- Fix for RedisCluster bulk response parsing [4121c4](https://www.github.com/phpredis/phpredis/commit/4121c4) ([Alberto Fernández](https://github.com/albertofem)) +- ValkeyArray segfault fix [564ce3](https://www.github.com/valkey-php/valkey-php/commit/564ce3) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) +- Small memory leak fix [645888b](https://www.github.com/valkey-php/valkey-php/commit/645888b) (Mike Grunder) +- Segfault fix when recreating ValkeyCluster objects [abf7d4](https://www.github.com/valkey-php/valkey-php/commit/abf7d4) ([Michael Grunder](https://github.com/michael-grunder)) +- Fix for ValkeyCluster bulk response parsing [4121c4](https://www.github.com/valkey-php/valkey-php/commit/4121c4) ([Alberto Fernández](https://github.com/albertofem)) --- -## [3.1.1] - 2017-02-01 ([GitHub](https://github.com/phpredis/phpredis/releases/tag/3.1.1), [PECL](https://pecl.php.net/package/redis/3.1.1)) +## [3.1.1] - 2017-02-01 ([GitHub](https://github.com/valkey-php/valkey-php/releases/tag/3.1.1), [PECL](https://pecl.php.net/package/redis/3.1.1)) This release contains mostly fixes for issues introduced when merging the php 5 and 7 codebase into a single branch. @@ -2301,112 +2301,112 @@ the php 5 and 7 codebase into a single branch. --- -## [3.1.0] - 2016-12-14 ([GitHub](https://github.com/phpredis/phpredis/releases/3.1.0), [PECL](https://pecl.php.net/package/redis/3.1.0)) +## [3.1.0] - 2016-12-14 ([GitHub](https://github.com/valkey-php/valkey-php/releases/3.1.0), [PECL](https://pecl.php.net/package/redis/3.1.0)) -In this version of phpredis codebase was unified to work with all versions of php \o/ +In this version of valkey-php codebase was unified to work with all versions of php \o/ Also many bug fixes and some improvements has been made. ### Added -- Support the client to Redis Cluster just having one master ([andyli](https://github.com/andyli029)) [892e5646](https://www.github.com/phpredis/phpredis/commit/892e5646) +- Support the client to Valkey Cluster just having one master ([andyli](https://github.com/andyli029)) [892e5646](https://www.github.com/valkey-php/valkey-php/commit/892e5646) - Allow both long and strings that are longs for zrangebyscore offset/limit - ([Michael Grunder](https://github.com/michael-grunder)) [bdcdd2aa](https://www.github.com/phpredis/phpredis/commit/bdcdd2aa) -- Process NX|XX, CH and INCR options in zAdd command [71c9f7c8](https://www.github.com/phpredis/phpredis/commit/71c9f7c8) + ([Michael Grunder](https://github.com/michael-grunder)) [bdcdd2aa](https://www.github.com/valkey-php/valkey-php/commit/bdcdd2aa) +- Process NX|XX, CH and INCR options in zAdd command [71c9f7c8](https://www.github.com/valkey-php/valkey-php/commit/71c9f7c8) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) ### Fixed -- Fix incrby/decrby for large integers ([Michael Grunder](https://github.com/michael-grunder)) [3a12758a](https://www.github.com/phpredis/phpredis/commit/3a12758a) -- Use static declarations for spl_ce_RuntimeException decl [a9857d69](https://www.github.com/phpredis/phpredis/commit/a9857d69) +- Fix incrby/decrby for large integers ([Michael Grunder](https://github.com/michael-grunder)) [3a12758a](https://www.github.com/valkey-php/valkey-php/commit/3a12758a) +- Use static declarations for spl_ce_RuntimeException decl [a9857d69](https://www.github.com/valkey-php/valkey-php/commit/a9857d69) ([Jeremy Mikola](https://github.com/jmikola)) - Fixed method call problem causes session handler to display two times - [24f86c49](https://www.github.com/phpredis/phpredis/commit/24f86c49) ([ZiHang Gao](https://github.com/cdoco)). -- PSETEX method returns '+OK' on success, not true [afcd8445](https://www.github.com/phpredis/phpredis/commit/afcd8445) ([sitri@ndxbn](https://github.com/ndxbn)) -- Fix integer overflow for long (>32bit) increments in hIncrBy [58e1d799](https://www.github.com/phpredis/phpredis/commit/58e1d799) + [24f86c49](https://www.github.com/valkey-php/valkey-php/commit/24f86c49) ([ZiHang Gao](https://github.com/cdoco)). +- PSETEX method returns '+OK' on success, not true [afcd8445](https://www.github.com/valkey-php/valkey-php/commit/afcd8445) ([sitri@ndxbn](https://github.com/ndxbn)) +- Fix integer overflow for long (>32bit) increments in hIncrBy [58e1d799](https://www.github.com/valkey-php/valkey-php/commit/58e1d799) ([@iyesin](https://github.com/iyesin)) -- Move zend_object handler to the end ([Michael Grunder](https://github.com/michael-grunder)) [34107966](https://www.github.com/phpredis/phpredis/commit/34107966) -- Using setOption on redis array causes immediate connection [f1a85b38](https://www.github.com/phpredis/phpredis/commit/f1a85b38) +- Move zend_object handler to the end ([Michael Grunder](https://github.com/michael-grunder)) [34107966](https://www.github.com/valkey-php/valkey-php/commit/34107966) +- Using setOption on redis array causes immediate connection [f1a85b38](https://www.github.com/valkey-php/valkey-php/commit/f1a85b38) ([Pavlo Yatsukhnenko](https://github.com/yatsukhnenko)) --- -## [3.0.0] - 2016-06-10 ([GitHub](https://github.com/phpredis/phpredis/releases/3.0.0), [PECL](https://pecl.php.net/package/redis/3.0.0)) +## [3.0.0] - 2016-06-10 ([GitHub](https://github.com/valkey-php/valkey-php/releases/3.0.0), [PECL](https://pecl.php.net/package/redis/3.0.0)) -This version of phpredis supports cluster and is intended for php versions -7.0.0 and higher. To compile cluster-enabled phpredis for older versions +This version of valkey-php supports cluster and is intended for php versions +7.0.0 and higher. To compile cluster-enabled valkey-php for older versions of php, please use the 2.2.8 pecl package. A huge thanks goes out to Sean DuBois for doing all the work required to get -phpredis working in php 7.0! +valkey-php working in php 7.0! ### Added -- PHP 7 Support [3159bd2](https://www.github.com/phpredis//phpredis/commit/3159bd2), - [567dc2f](https://www.github.com/phpredis//phpredis/commit/567dc2f), [daa4d9f](https://www.github.com/phpredis//phpredis/commit/daa4d9f), - [f2711e3](https://www.github.com/phpredis//phpredis/commit/f2711e3), [9cb9d07](https://www.github.com/phpredis//phpredis/commit/9cb9d07), - [d51c89](https://www.github.com/phpredis//phpredis/commit/d51c89), [9ff8f49](https://www.github.com/phpredis//phpredis/commit/9ff8f49), - [33bb629](https://www.github.com/phpredis//phpredis/commit/33bb629), [cbdf65a](https://www.github.com/phpredis//phpredis/commit/cbdf65a), - [f30b7fd](https://www.github.com/phpredis//phpredis/commit/f30b7fd), [c687a51](https://www.github.com/phpredis//phpredis/commit/c687a51), - [6b3e773](https://www.github.com/phpredis//phpredis/commit/6b3e773), [2bf8241](https://www.github.com/phpredis//phpredis/commit/2bf8241), - [71bd3d](https://www.github.com/phpredis//phpredis/commit/71bd3d), [9221ca4](https://www.github.com/phpredis//phpredis/commit/9221ca4), - [4e00df6](https://www.github.com/phpredis//phpredis/commit/4e00df6), [e2407ca](https://www.github.com/phpredis//phpredis/commit/e2407ca), - [97fcfe6](https://www.github.com/phpredis//phpredis/commit/97fcfe6), [77e6200](https://www.github.com/phpredis//phpredis/commit/77e6200) +- PHP 7 Support [3159bd2](https://www.github.com/valkey-php//valkey-php/commit/3159bd2), + [567dc2f](https://www.github.com/valkey-php//valkey-php/commit/567dc2f), [daa4d9f](https://www.github.com/valkey-php//valkey-php/commit/daa4d9f), + [f2711e3](https://www.github.com/valkey-php//valkey-php/commit/f2711e3), [9cb9d07](https://www.github.com/valkey-php//valkey-php/commit/9cb9d07), + [d51c89](https://www.github.com/valkey-php//valkey-php/commit/d51c89), [9ff8f49](https://www.github.com/valkey-php//valkey-php/commit/9ff8f49), + [33bb629](https://www.github.com/valkey-php//valkey-php/commit/33bb629), [cbdf65a](https://www.github.com/valkey-php//valkey-php/commit/cbdf65a), + [f30b7fd](https://www.github.com/valkey-php//valkey-php/commit/f30b7fd), [c687a51](https://www.github.com/valkey-php//valkey-php/commit/c687a51), + [6b3e773](https://www.github.com/valkey-php//valkey-php/commit/6b3e773), [2bf8241](https://www.github.com/valkey-php//valkey-php/commit/2bf8241), + [71bd3d](https://www.github.com/valkey-php//valkey-php/commit/71bd3d), [9221ca4](https://www.github.com/valkey-php//valkey-php/commit/9221ca4), + [4e00df6](https://www.github.com/valkey-php//valkey-php/commit/4e00df6), [e2407ca](https://www.github.com/valkey-php//valkey-php/commit/e2407ca), + [97fcfe6](https://www.github.com/valkey-php//valkey-php/commit/97fcfe6), [77e6200](https://www.github.com/valkey-php//valkey-php/commit/77e6200) [Sean DuBois](https://github.com/Sean-Der) -- Redis Cluster support +- Valkey Cluster support - IPv6 support ### Changed - Allow SINTERSTORE to take a single array argument again -- Exception handling improvement [Jan-E](https://github.com/Jan-E) [314a2c3c](https://www.github.com/phpredis//phpredis/commit/314a2c3c) -- Allow '-' and '+' in ZRANGEBYLEX [Patrick Pokatilo](https://github.com/SHyx0rmZ) [8bfa2188](https://www.github.com/phpredis//phpredis/commit/8bfa2188) +- Exception handling improvement [Jan-E](https://github.com/Jan-E) [314a2c3c](https://www.github.com/valkey-php//valkey-php/commit/314a2c3c) +- Allow '-' and '+' in ZRANGEBYLEX [Patrick Pokatilo](https://github.com/SHyx0rmZ) [8bfa2188](https://www.github.com/valkey-php//valkey-php/commit/8bfa2188) ### Fixed -- config.w32 fix [Jan-E](https://github.com/Jan-E) [495d308](https://www.github.com/phpredis//phpredis/commit/495d308), [c9e0b682](https://www.github.com/phpredis//phpredis/commit/c9e0b682) -- Unit test fix for max int value [Jan-E](https://github.com/Jan-E) [659ea2aa](https://www.github.com/phpredis//phpredis/commit/659ea2aa) -- unsigned long -> zend_ulong fix [Jan-E](https://github.com/Jan-E) [4d66e3d4](https://www.github.com/phpredis//phpredis/commit/4d66e3d4) -- Visual Stuio 14 fixes [Jan-E](https://github.com/Jan-E) [ea98401c](https://www.github.com/phpredis//phpredis/commit/ea98401c) -- Segfault fix when looking up our socket [ephemeralsnow](https://github.com/ephemeralsnow) [0126481a](https://www.github.com/phpredis//phpredis/commit/0126481a) -- Documentation fixes [Ares](https://github.com/ares333) [54b9a0ec](https://www.github.com/phpredis//phpredis/commit/54b9a0ec) -- php7 related memory leak fix [Stuart Carnie](https://github.com/stuartcarnie) [b75bf3b4](https://www.github.com/phpredis//phpredis/commit/b75bf3b4) -- Potential segfault fix in cluster session [Sergei Lomakov](https://github.com/sapfeer0k) [661fb5b1](https://www.github.com/phpredis//phpredis/commit/661fb5b1) -- php7 related serialization leak fix (Adam Harvey) [c40fc1d8](https://www.github.com/phpredis//phpredis/commit/c40fc1d8) +- config.w32 fix [Jan-E](https://github.com/Jan-E) [495d308](https://www.github.com/valkey-php//valkey-php/commit/495d308), [c9e0b682](https://www.github.com/valkey-php//valkey-php/commit/c9e0b682) +- Unit test fix for max int value [Jan-E](https://github.com/Jan-E) [659ea2aa](https://www.github.com/valkey-php//valkey-php/commit/659ea2aa) +- unsigned long -> zend_ulong fix [Jan-E](https://github.com/Jan-E) [4d66e3d4](https://www.github.com/valkey-php//valkey-php/commit/4d66e3d4) +- Visual Stuio 14 fixes [Jan-E](https://github.com/Jan-E) [ea98401c](https://www.github.com/valkey-php//valkey-php/commit/ea98401c) +- Segfault fix when looking up our socket [ephemeralsnow](https://github.com/ephemeralsnow) [0126481a](https://www.github.com/valkey-php//valkey-php/commit/0126481a) +- Documentation fixes [Ares](https://github.com/ares333) [54b9a0ec](https://www.github.com/valkey-php//valkey-php/commit/54b9a0ec) +- php7 related memory leak fix [Stuart Carnie](https://github.com/stuartcarnie) [b75bf3b4](https://www.github.com/valkey-php//valkey-php/commit/b75bf3b4) +- Potential segfault fix in cluster session [Sergei Lomakov](https://github.com/sapfeer0k) [661fb5b1](https://www.github.com/valkey-php//valkey-php/commit/661fb5b1) +- php7 related serialization leak fix (Adam Harvey) [c40fc1d8](https://www.github.com/valkey-php//valkey-php/commit/c40fc1d8) --- -## [2.2.8] - 2016-06-02 ([GitHub](https://github.com/phpredis/phpredis/releases/2.2.8), [PECL](https://pecl.php.net/package/redis/2.2.8)) +## [2.2.8] - 2016-06-02 ([GitHub](https://github.com/valkey-php/valkey-php/releases/2.2.8), [PECL](https://pecl.php.net/package/redis/2.2.8)) -The main improvement in this version of phpredis is support for Redis -Cluster. This version of phpredis is intended for versions of php older +The main improvement in this version of valkey-php is support for Valkey +Cluster. This version of valkey-php is intended for versions of php older than 7. ### Added - Added randomization to our seed nodes to balance which instance is used - to map the keyspace [32eb1c5f](https://www.github.com/phpredis/phpredis/commit/32eb1c5f) (Vitaliy Stepanyuk) + to map the keyspace [32eb1c5f](https://www.github.com/valkey-php/valkey-php/commit/32eb1c5f) (Vitaliy Stepanyuk) - Added support for IPv6 addresses ### Fixed -- PHP liveness checking workaround (Shafreeck Sea) [c18d58b9](https://www.github.com/phpredis/phpredis/commit/c18d58b9) +- PHP liveness checking workaround (Shafreeck Sea) [c18d58b9](https://www.github.com/valkey-php/valkey-php/commit/c18d58b9) - Various documentation and code formatting and style fixes ([ares333](https://github.com/ares333), [sanpili](https://github.com/sanpili), [Bryan Nelson](https://github.com/bplus), [linfangrong](https://github.com/linfangrong), [Romero Malaquias](https://github.com/RomeroMalaquias), [Viktor Szépe](https://github.com/szepeviktor)) - Fix scan reply processing to use long instead of int to avoid overflow [mixiaojiong](https://github.com/mixiaojiong)). -- Fix potential segfault in Redis Cluster session storage [cc15aae](https://www.github.com/phpredis/phpredis/commit/cc15aae) +- Fix potential segfault in Valkey Cluster session storage [cc15aae](https://www.github.com/valkey-php/valkey-php/commit/cc15aae) ([Sergei Lomakov](https://github.com/sapfeer0k)). -- Fixed memory leak in discard function [17b1f427](https://www.github.com/phpredis/phpredis/commit/17b1f427) +- Fixed memory leak in discard function [17b1f427](https://www.github.com/valkey-php/valkey-php/commit/17b1f427) - Sanity check for igbinary unserialization - [3266b222](https://www.github.com/phpredis/phpredis/commit/3266b222), [528297a](https://www.github.com/phpredis/phpredis/commit/528297a) ([Maurus Cuelenaere](https://github.com/mcuelenaere)). -- Fix segfault occurring from unclosed socket connection for Redis Cluster - [04196aee](https://www.github.com/phpredis/phpredis/commit/04196aee) ([CatKang](https://github.com/CatKang)) + [3266b222](https://www.github.com/valkey-php/valkey-php/commit/3266b222), [528297a](https://www.github.com/valkey-php/valkey-php/commit/528297a) ([Maurus Cuelenaere](https://github.com/mcuelenaere)). +- Fix segfault occurring from unclosed socket connection for Valkey Cluster + [04196aee](https://www.github.com/valkey-php/valkey-php/commit/04196aee) ([CatKang](https://github.com/CatKang)) - Case insensitive zRangeByScore options - Fixed dreaded size_t vs long long compiler warning --- -## [2.2.7] - 2015-03-03 ([GitHub](https://github.com/phpredis/phpredis/releases/tag/2.2.7), [PECL](https://pecl.php.net/package/redis/2.2.7)) +## [2.2.7] - 2015-03-03 ([GitHub](https://github.com/valkey-php/valkey-php/releases/tag/2.2.7), [PECL](https://pecl.php.net/package/redis/2.2.7)) ### Added @@ -2418,13 +2418,13 @@ than 7. - Implemented rawCommand() so clients can send arbitrary things to the redis server - Implemented DEBUG OBJECT ([@michael-grunder](https://github.com/michael-grunder), [@isage](https://github.com/isage)) -- Added/abide by connect timeout for RedisArray +- Added/abide by connect timeout for ValkeyArray ### Fixed -- Select to the last selected DB when phpredis reconnects +- Select to the last selected DB when valkey-php reconnects - Fix a possible invalid free in \_serialize() -- Added SAVE and BGSAVE to "distributable" commands for RedisArray +- Added SAVE and BGSAVE to "distributable" commands for ValkeyArray - Fixed invalid "argc" calculation in HLL commands ([@welting](https://github.com/weltling)) - Allow clients to break out of the subscribe loop and return context. - Fixes a memory leak in SCAN when OPT_SCAN_RETRY id. @@ -2435,12 +2435,12 @@ than 7. --- -## [2.2.5] - 2014-03-15 ([GitHub](https://github.com/phpredis/phpredis/releases/tag/2.2.5), [PECL](https://pecl.php.net/package/redis/2.2.5)) +## [2.2.5] - 2014-03-15 ([GitHub](https://github.com/valkey-php/valkey-php/releases/tag/2.2.5), [PECL](https://pecl.php.net/package/redis/2.2.5)) ### Added - Support for the BITPOS command -- Connection timeout option for RedisArray ([@MiketoString](https://github.com/MiketoString)) +- Connection timeout option for ValkeyArray ([@MiketoString](https://github.com/MiketoString)) - A \_serialize method, to complement our existing \_unserialize method - Support for the PUBSUB command - Support for SCAN, SSCAN, HSCAN, and ZSCAN @@ -2454,15 +2454,15 @@ than 7. --- -## [2.2.4] - 2013-09-01 ([GitHub](https://github.com/phpredis/phpredis/releases/tag/2.2.4), [PECL](https://pecl.php.net/package/redis/2.2.4)) +## [2.2.4] - 2013-09-01 ([GitHub](https://github.com/valkey-php/valkey-php/releases/tag/2.2.4), [PECL](https://pecl.php.net/package/redis/2.2.4)) ### Added -- Randomized reconnect delay for RedisArray @mobli -- Lazy connections to RedisArray servers @mobli +- Randomized reconnect delay for ValkeyArray @mobli +- Lazy connections to ValkeyArray servers @mobli - Allow LONG and STRING keys in MGET/MSET -- Extended SET options for Redis >= 2.6.12 -- Persistent connections and UNIX SOCKET support for RedisArray +- Extended SET options for Valkey >= 2.6.12 +- Persistent connections and UNIX SOCKET support for ValkeyArray - Allow aggregates for ZUNION/ZINTER without weights @mheijkoop - Support for SLOWLOG command diff --git a/INSTALL.md b/INSTALL.md index 0f7c4b6ed0..c01e6eb9a3 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -11,21 +11,21 @@ pecl install redis To build this extension for the sources tree: ```bash -git clone https://github.com/phpredis/phpredis.git -cd phpredis +git clone https://github.com/valkey-php/valkey-php.git +cd valkey-php phpize ./configure [--enable-redis-igbinary] [--enable-redis-msgpack] [--enable-redis-lzf [--with-liblzf[=DIR]]] [--enable-redis-zstd] [--enable-redis-lz4] make && make install ``` -If you would like phpredis to serialize your data using the igbinary library, run configure with `--enable-redis-igbinary`. +If you would like valkey-php to serialize your data using the igbinary library, run configure with `--enable-redis-igbinary`. If you would like to use the msgpack serializer, run configure with `--enable-redis-msgpack` (note: Requires php-msgpack >= 2.0.3) -The extension also may compress data before sending it to Redis server, if you run configure with `--enable-redis-lzf`. If you want to use lzf library pre-installed into your system use `--with-liblzf` configuration option to specify the path where to search files. +The extension also may compress data before sending it to Valkey server, if you run configure with `--enable-redis-lzf`. If you want to use lzf library pre-installed into your system use `--with-liblzf` configuration option to specify the path where to search files. `make install` copies `redis.so` to an appropriate location, but you still need to enable the module in the PHP config file. To do so, either edit your php.ini or add a redis.ini file in `/etc/php5/conf.d` with the following contents: `extension=redis.so`. You can generate a debian package for PHP5, accessible from Apache 2 by running `./mkdeb-apache2.sh` or with `dpkg-buildpackage` or `svn-buildpackage`. -This extension exports a single class, [Redis](./README.md#class-redis) (and [RedisException](./README.md#class-redisexception) used in case of errors). Check out https://github.com/ukko/phpredis-phpdoc for a PHP stub that you can use in your IDE for code completion. +This extension exports a single class, [Valkey](./README.md#class-redis) (and [ValkeyException](./README.md#class-redisexception) used in case of errors). Check out https://github.com/ukko/valkey-php-phpdoc for a PHP stub that you can use in your IDE for code completion. # Binary packages @@ -78,9 +78,9 @@ export CFLAGS CXXFLAGS LDFLAGS CCFLAGS MACOSX_DEPLOYMENT_TARGET If that still fails and you are running Zend Server CE, try this right before "make": `./configure CFLAGS="-arch i386"`. -Taken from [Compiling phpredis on Zend Server CE/OSX ](http://www.tumblr.com/tagged/phpredis). +Taken from [Compiling valkey-php on Zend Server CE/OSX ](http://www.tumblr.com/tagged/valkey-php). -See also: [Install Redis & PHP Extension PHPRedis with Macports](http://www.lecloud.net/post/3378834922/install-redis-php-extension-phpredis-with-macports). +See also: [Install Valkey & PHP Extension PHPValkey with Macports](http://www.lecloud.net/post/3378834922/install-redis-php-extension-valkey-php-with-macports). You can install it using MacPorts: @@ -89,4 +89,4 @@ You can install it using MacPorts: # Building on Windows -See [instructions from @char101](https://github.com/phpredis/phpredis/issues/213#issuecomment-11361242) on how to build phpredis on Windows. +See [instructions from @char101](https://github.com/valkey-php/valkey-php/issues/213#issuecomment-11361242) on how to build valkey-php on Windows. diff --git a/README.md b/README.md index 0134fd2097..7de9e5cbd2 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # Valkey-PHP

- Valkey-PHP Logo + Valkey Logo + PHP Logo

@@ -19,23 +20,12 @@ Valkey-PHP is a comprehensive PHP client for [Valkey](https://valkey.io), design ### Key Features - **Complete Valkey Command Coverage**: 100% support for all Valkey commands with comprehensive test coverage -- **High-Level Abstractions**: Similar to Redisson in Java, offering object-oriented interfaces for complex data structures +- **High-Level Abstractions**: Similar to Valkeyson in Java, offering object-oriented interfaces for complex data structures - **Dual Interface**: Both a PHP extension (for maximum performance) and a pure PHP implementation (for maximum compatibility) - **Forever Open Source**: BSD-3-Clause license under the Linux Foundation ensures the project remains open and free -- **Valkey Compatibility**: Maintained in sync with Valkey development while preserving compatibility with Redis OSS +- **Valkey Compatibility**: Maintained in sync with Valkey development while preserving compatibility with Valkey OSS - **Enterprise-Ready**: Clustering, sentinel support, connection pooling, and other features needed for production deployments -## Pre-requisites - -```bash -brew install valkey -brew services start valkey -brew services list -valkey-cli INFO server - -brew install autoconf automake libtool php -``` - ## Installation ### PHP Extension (Recommended for Production) @@ -87,7 +77,7 @@ echo $map->get('name'); // Outputs: Robert ## High-Level Abstractions -Valkey-PHP provides Redisson-like abstractions for complex data structures: +Valkey-PHP provides Valkeyson-like abstractions for complex data structures: - Maps: ```php $map = $valkey->getMap('map-key');``` - Lists: ```php $list = $valkey->getList('list-key');``` @@ -99,4639 +89,320 @@ Valkey-PHP provides Redisson-like abstractions for complex data structures: ## Project Goals -- Unified API: Merge the strengths of phpredis (performance) and webdcg/redis (developer experience) +- Unified API: Merge the strengths of valkey-php (performance) and webdcg/redis (developer experience) - 100% Command Coverage: Support all Valkey commands with comprehensive tests - Open Source Forever: BSD-3-Clause license under Linux Foundation governance -- Valkey Compatibility: Stay in sync with Valkey while maintaining Redis OSS compatibility -- High-Level Abstractions: Provide Java Redisson-like interfaces for PHP developers +- Valkey Compatibility: Stay in sync with Valkey while maintaining Valkey OSS compatibility +- High-Level Abstractions: Provide Java Valkeyson-like interfaces for PHP developers - Performance: Optimize for speed while maintaining clean interfaces -### Migrating from phpredis or webdcg/redis +### Migrating from valkey-php or webdcg/redis We provide compatibility layers to make migration from either library as smooth as possible: ```php -// For PHPRedis users -use Valkey\Compat\Redis; -$redis = new Redis(); +// For PHPValkey users +use Valkey\Compat\Valkey; +$valkey = new Valkey(); // For webdcg/redis users -use Valkey\Compat\WebdcgRedis; -$redis = new WebdcgRedis(); +use Valkey\Compat\WebdcgValkey; +$valkey = new WebdcgValkey(); ``` ## Documentation Comprehensive documentation is available at [valkey-php.dev/docs](https://valkey-php.dev/docs) -## Contributing - -We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to get started. - -## Testing - -Valkey-PHP maintains 100% code coverage for all Valkey commands: - -```bash -composer test -``` - -### License - -Valkey-PHP is open-sourced software licensed under the BSD-3-Clause license. - -### Acknowledgements - -This project builds upon the excellent work of: - -- phpredis/phpredis -- webdcg/redis - -We thank all the contributors to these projects for their valuable work. - -## Support - -- GitHub Issues -- Discord Community -- Stack Overflow - -

Linux Foundation

``` - -This README provides a comprehensive overview of your project goals, highlighting the merger of phpredis and webdcg/redis under the Linux Foundation with BSD-3 licensing. It emphasizes the key features like 100% Valkey command coverage, high-level abstractions similar to Redisson, and the commitment to open source. The document includes installation instructions, quick start examples, migration paths, and acknowledges the original projects. - ------ - -# PhpRedis - -[![Build Status](https://github.com/phpredis/phpredis/actions/workflows/ci.yml/badge.svg)](https://github.com/phpredis/phpredis/actions/workflows/ci.yml) -[![Coverity Scan Build Status](https://scan.coverity.com/projects/13205/badge.svg)](https://scan.coverity.com/projects/phpredis-phpredis) -[![PHP version](https://img.shields.io/badge/php-%3E%3D%207.0-8892BF.svg)](https://github.com/phpredis/phpredis) - -The phpredis extension provides an API for communicating with the [Redis](http://redis.io/) key-value store. It also supports [KeyDB](https://docs.keydb.dev/) and [Valkey](https://valkey.io/), which are open source alternatives to Redis. - -It is released under the [PHP License, version 3.01](http://www.php.net/license/3_01.txt). - -You can send comments, patches, questions [here on github](https://github.com/phpredis/phpredis/issues), to michael.grunder@gmail.com ([Twitter](https://twitter.com/grumi78), Mastodon), p.yatsukhnenko@gmail.com ([@yatsukhnenko](https://twitter.com/yatsukhnenko)), or n.favrefelix@gmail.com ([@yowgi](https://twitter.com/yowgi)). - -## [API Documentation](https://phpredis.github.io/phpredis) -These are a work in progress, but will eventually replace our **ONE README TO RULE THEM ALL** docs. - -## Supporting the project - -PhpRedis will always be free and open source software, but if you or your company has found it useful please consider supporting the project. Developing a large, complex, and performant library like PhpRedis takes a great deal of time and effort, and support would be appreciated! :heart: - -The best way to support the project is through [GitHub sponsors](https://github.com/sponsors/michael-grunder). Many of the reward tiers grant access to our [slack channel](https://phpredis.slack.com) where [myself](https://github.com/michael-grunder) and [Pavlo](https://github.com/yatsukhnenko) are regularly available to answer questions. Additionally this will allow you to provide feedback on which fixes and new features to prioritize. - -You can also make a one-time contribution with [![PayPal](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.me/michaelgrunder/5) - -## Sponsors - -Audiomack.com -Bluehost.com -Object Cache Pro -OpenLMS.net - -## Table of contents - ------ - -1. [Installing/Configuring](docs/content/README.md#installingconfiguring) - * [Installation](docs/content/installation.md) - * [PHP Session handler](docs/content/php.md-session-handler) - * [Distributed Redis Array](./arrays.md#readme) - * [Redis Cluster support](./cluster.md#readme) - * [Redis Sentinel support](./sentinel.md#readme) - * [Running the unit tests](docs/content/running.md-the-unit-tests) -2. [Classes and methods](docs/content/classes.md-and-methods) - * [Usage](docs/content/usage.md) - * [Connection](docs/content/connection.md) - * [Retry and backoff](docs/content/retry.md-and-backoff) - * [Server](docs/content/server.md) - * [Keys and strings](docs/content/keys.md-and-strings) - * [Hashes](docs/content/hashes.md) - * [Lists](docs/content/lists.md) - * [Sets](docs/content/sets.md) - * [Sorted sets](docs/content/sorted.md-sets) - * [HyperLogLogs](docs/content/hyperloglogs.md) - * [Geocoding](docs/content/geocoding.md) - * [Streams](docs/content/streams.md) - * [Pub/sub](docs/content/pubsub.md) - * [Transactions](docs/content/transactions.md) - * [Scripting](docs/content/scripting.md) - * [Introspection](docs/content/introspection.md) - ------ - -# Installing/Configuring - ------ - -## Installation - -For everything you should need to install PhpRedis on your system, -see the [INSTALL.md](./INSTALL.md) page. - -## PHP Session handler - -phpredis can be used to store PHP sessions. To do this, configure `session.save_handler` and `session.save_path` in your php.ini to tell phpredis where to store the sessions. - -`session.save_path` can have a simple `host:port` format too, but you need to provide the `tcp://` scheme if you want to use the parameters. The following parameters are available: - -* weight (integer): the weight of a host is used in comparison with the others in order to customize the session distribution on several hosts. If host A has twice the weight of host B, it will get twice the amount of sessions. In the example, *host1* stores 20% of all the sessions (1/(1+2+2)) while *host2* and *host3* each store 40% (2/(1+2+2)). The target host is determined once and for all at the start of the session, and doesn't change. The default weight is 1. -* timeout (float): the connection timeout to a redis host, expressed in seconds. If the host is unreachable in that amount of time, the session storage will be unavailable for the client. The default timeout is very high (86400 seconds). -* persistent (integer, should be 1 or 0): defines if a persistent connection should be used. -* prefix (string, defaults to "PHPREDIS_SESSION:"): used as a prefix to the Redis key in which the session is stored. The key is composed of the prefix followed by the session ID. -* auth (string, or an array with one or two elements): used to authenticate with the server prior to sending commands. -* database (integer): selects a different database. - -Sessions have a lifetime expressed in seconds and stored in the INI variable "session.gc_maxlifetime". You can change it with [`ini_set()`](http://php.net/ini_set). -The session handler requires a version of Redis supporting `EX` and `NX` options of `SET` command (at least 2.6.12). -phpredis can also connect to a unix domain socket: `session.save_path = "unix:///var/run/redis/redis.sock?persistent=1&weight=1&database=0"`. - -### Examples - -Multiple Redis servers: -``` -session.save_handler = redis -session.save_path = "tcp://host1:6379?weight=1, tcp://host2:6379?weight=2&timeout=2.5, tcp://host3:6379?weight=2&read_timeout=2.5" -``` - -Login to Redis using username and password: -``` -session.save_handler = redis -session.save_path = "tcp://127.0.0.1:6379?auth[]=user&auth[]=password" -``` - -Login to Redis using username, password, and set prefix: -``` -session.save_handler = redis -session.save_path = "tcp://127.0.0.1:6379?auth[]=user&auth[]=password&prefix=user_PHPREDIS_SESSION:" -``` - -### Session locking - -**Support**: Locking feature is currently only supported for Redis setup with single master instance (e.g. classic master/slave Sentinel environment). -So locking may not work properly in RedisArray or RedisCluster environments. - -Following INI variables can be used to configure session locking: -``` -; Should the locking be enabled? Defaults to: 0. -redis.session.locking_enabled = 1 -; How long should the lock live (in seconds)? Defaults to: value of max_execution_time. -redis.session.lock_expire = 60 -; How long to wait between attempts to acquire lock, in microseconds (µs)?. Defaults to: 20000 -redis.session.lock_wait_time = 50000 -; Maximum number of times to retry (-1 means infinite). Defaults to: 100 -redis.session.lock_retries = 2000 -``` - -### Session compression - -Following INI variables can be used to configure session compression: -``` -; Should session compression be enabled? Possible values are zstd, lzf, lz4, none. Defaults to: none -redis.session.compression = zstd -; What compression level should be used? Compression level depends on used library. For most deployments range 1-9 should be fine. Defaults to: 3 -redis.session.compression_level = 3 -``` - -## Running the unit tests - -phpredis uses a small custom unit test suite for testing functionality of the various classes. To run tests, simply do the following: - -``` -# Run tests for Redis class (note this is the default) -php tests/TestRedis.php --class Redis - -# Run tests for RedisArray class -tests/mkring.sh start -php tests/TestRedis.php --class RedisArray -tests/mkring.sh stop - -# Run tests for the RedisCluster class -tests/make-cluster.sh start -php tests/TestRedis.php --class RedisCluster -tests/make-cluster.sh stop - -# Run tests for RedisSentinel class -php tests/TestRedis.php --class RedisSentinel -``` - -Note that it is possible to run only tests which match a substring of the test itself by passing the additional argument '--test ' when invoking. - -``` -# Just run the 'echo' test -php tests/TestRedis.php --class Redis --test echo -``` - -# Classes and methods ------ - -## Usage - -1. [Class Redis](#class-redis) -1. [Class RedisException](#class-redisexception) -1. [Predefined constants](#predefined-constants) - -### Class Redis ------ -_**Description**_: Creates a Redis client - -##### *Example* - -```php -$redis = new Redis(); -``` - -Starting from version 6.0.0 it's possible to specify configuration options. -This allows to connect lazily to the server without explicitly invoking `connect` command. - -##### *Example* - -```php -$redis = new Redis([ - 'host' => '127.0.0.1', - 'port' => 6379, - 'connectTimeout' => 2.5, - 'auth' => ['phpredis', 'phpredis'], - 'ssl' => ['verify_peer' => false], - 'backoff' => [ - 'algorithm' => Redis::BACKOFF_ALGORITHM_DECORRELATED_JITTER, - 'base' => 500, - 'cap' => 750, - ], -]); -``` - -##### *Parameters* - -*host*: string. can be a host, or the path to a unix domain socket. -*port*: int (default is 6379, should be -1 for unix domain socket) -*connectTimeout*: float, value in seconds (default is 0 meaning unlimited) -*retryInterval*: int, value in milliseconds (optional) -*readTimeout*: float, value in seconds (default is 0 meaning unlimited) -*persistent*: mixed, if value is string then it used as persistend id, else value casts to boolean -*auth*: mixed, authentication information -*ssl*: array, SSL context options - -### Class RedisException ------ -phpredis throws a [RedisException](#class-redisexception) object if it can't reach the Redis server. That can happen in case of connectivity issues, -if the Redis service is down, or if the redis host is overloaded. In any other problematic case that does not involve an -unreachable server (such as a key not existing, an invalid command, etc), phpredis will return `FALSE`. - -### Predefined constants ------ -_**Description**_: Available Redis Constants - -Redis data types, as returned by [type](#type) -``` -Redis::REDIS_STRING - String -Redis::REDIS_SET - Set -Redis::REDIS_LIST - List -Redis::REDIS_ZSET - Sorted set -Redis::REDIS_HASH - Hash -Redis::REDIS_NOT_FOUND - Not found / other -``` - -@TODO: OPT_SERIALIZER, AFTER, BEFORE,... - -## Connection - -1. [connect, open](#connect-open) - Connect to a server -1. [pconnect, popen](#pconnect-popen) - Connect to a server (persistent) -1. [auth](#auth) - Authenticate to the server -1. [select](#select) - Change the selected database for the current connection -1. [swapdb](#swapdb) - Swaps two Redis databases -1. [close](#close) - Close the connection -1. [setOption](#setoption) - Set client option -1. [getOption](#getoption) - Get client option -1. [ping](#ping) - Ping the server -1. [echo](#echo) - Echo the given string - -### connect, open ------ -_**Description**_: Connects to a Redis instance. - -##### *Parameters* - -*host*: string. can be a host, or the path to a unix domain socket. Starting from version 5.0.0 it is possible to specify schema -*port*: int, optional -*timeout*: float, value in seconds (optional, default is 0 meaning it will use default_socket_timeout) -*reserved*: should be '' if retry_interval is specified -*retry_interval*: int, value in milliseconds (optional) -*read_timeout*: float, value in seconds (optional, default is 0 meaning it will use default_socket_timeout) -*others*: array, with PhpRedis >= 5.3.0, it allows setting _auth_ and [_stream_](https://www.php.net/manual/en/context.ssl.php) configuration. - -##### *Return value* - -*BOOL*: `TRUE` on success, `FALSE` on error. - -##### *Example* - -```php -$redis->connect('127.0.0.1', 6379); -$redis->connect('127.0.0.1'); // port 6379 by default -$redis->connect('tls://127.0.0.1', 6379); // enable transport level security. -$redis->connect('tls://127.0.0.1'); // enable transport level security, port 6379 by default. -$redis->connect('127.0.0.1', 6379, 2.5); // 2.5 sec timeout. -$redis->connect('/tmp/redis.sock'); // unix domain socket. -$redis->connect('127.0.0.1', 6379, 1, '', 100); // 1 sec timeout, 100ms delay between reconnection attempts. -$redis->connect('/tmp/redis.sock', 0, 1.5, NULL, 0, 1.5); // Unix socket with 1.5s timeouts (connect and read) - -/* With PhpRedis >= 5.3.0 you can specify authentication and stream information on connect */ -$redis->connect('127.0.0.1', 6379, 1, '', 0, 0, ['auth' => ['phpredis', 'phpredis']]); -``` - -**Note:** `open` is an alias for `connect` and will be removed in future versions of phpredis. - -### pconnect, popen ------ -_**Description**_: Connects to a Redis instance or reuse a connection already established with `pconnect`/`popen`. - -The connection will not be closed on end of request until the php process ends. -So be prepared for too many open FD's errors (specially on redis server side) when using persistent -connections on many servers connecting to one redis server. - -Also more than one persistent connection can be made identified by either host + port + timeout -or host + persistent_id or unix socket + timeout. +Table of contents +---- + +1. [Installation](#installation) +2. [Classes and methods](#classes-and-methods) + - [Usage](#usage) + - [Bitmaps](#bitmaps) + - [Connection](#connection) + - [Geospatial Indexes](#geospatial-indexes) + - [Hashes](#hashes) + - [HyperLogLogs](#HyperLogLogs) + - [Introspection](#introspection) + - [Keys](#keys) + - [Lists](#lists) + - [Pub/sub](#pubsub) + - [Scripting](#scripting) + - [Sets](#sets) + - [Sorted sets](#sorted-sets) + - [Streams](#Streams) + - [Strings](#strings) + - [Transactions](#transactions) + +## Classes and methods + +### [Usage](docs/content/usage.md) -Starting from version 4.2.1, it became possible to use connection pooling by setting INI variable `redis.pconnect.pooling_enabled` to 1. - -This feature is not available in threaded versions. `pconnect` and `popen` then working like their non -persistent equivalents. - -##### *Parameters* - -*host*: string. can be a host, or the path to a unix domain socket. Starting from version 5.0.0 it is possible to specify schema -*port*: int, optional -*timeout*: float, value in seconds (optional, default is 0 meaning it will use default_socket_timeout) -*persistent_id*: string. identity for the requested persistent connection -*retry_interval*: int, value in milliseconds (optional) -*read_timeout*: float, value in seconds (optional, default is 0 meaning it will use default_socket_timeout) - -##### *Return value* - -*BOOL*: `TRUE` on success, `FALSE` on error. - -##### *Example* - -```php -$redis->pconnect('127.0.0.1', 6379); -$redis->pconnect('127.0.0.1'); // port 6379 by default - same connection like before. -$redis->pconnect('tls://127.0.0.1', 6379); // enable transport level security. -$redis->pconnect('tls://127.0.0.1'); // enable transport level security, port 6379 by default. -$redis->pconnect('127.0.0.1', 6379, 2.5); // 2.5 sec timeout and would be another connection than the two before. -$redis->pconnect('127.0.0.1', 6379, 2.5, 'x'); // x is sent as persistent_id and would be another connection than the three before. -$redis->pconnect('/tmp/redis.sock'); // unix domain socket - would be another connection than the four before. -``` - -**Note:** `popen` is an alias for `pconnect` and will be removed in future versions of phpredis. - -### auth ------ -_**Description**_: Authenticate the connection using a password or a username and password. -*Warning*: The password is sent in plain-text over the network. - -##### *Parameters* -*MIXED*: password - -##### *Return value* -*BOOL*: `TRUE` if the connection is authenticated, `FALSE` otherwise. - -*Note*: In order to authenticate with a username and password you need Redis >= 6.0. - -##### *Example* ```php -/* Authenticate with the password 'foobared' */ -$redis->auth('foobared'); - -/* Authenticate with the username 'phpredis', and password 'haxx00r' */ -$redis->auth(['phpredis', 'haxx00r']); - -/* Authenticate with the password 'foobared' */ -$redis->auth(['foobared']); - -/* You can also use an associative array specifying user and pass */ -$redis->auth(['user' => 'phpredis', 'pass' => 'phpredis']); -$redis->auth(['pass' => 'phpredis']); +$valkey = new Valkey(); ``` -### select ------ -_**Description**_: Change the selected database for the current connection. - -##### *Parameters* -*INTEGER*: dbindex, the database number to switch to. - -##### *Return value* -`TRUE` in case of success, `FALSE` in case of failure. -##### *Example* -See method for example: [move](#move) - -### swapdb ------ -_**Description**_: Swap one Redis database with another atomically - -##### *Parameters* -*INTEGER*: db1 -*INTEGER*: db2 - -##### *Return value* -`TRUE` on success and `FALSE` on failure. +### [Bitmaps](docs/content/bitmaps.md) -*Note*: Requires Redis >= 4.0.0 - -##### *Example* ```php -$redis->swapdb(0, 1); /* Swaps DB 0 with DB 1 atomically */ +$valkey = new Valkey(); +$valkey->bitCount('key'); +$valkey->bitField('key', 'INCRBY, 'i5', 100, 1, 'GET', 'u4', 0); +$valkey->bitFieldReadOnly('key', 'INCRBY, 'i5', 100, 1, 'GET', 'u4', 0); +$valkey->bitOp('and', 'testBitOpAnd', 'testBit1', 'testBit2'); +$valkey->bitpos('key', 0); +$valkey->getBit('key', 5); +$valkey->setBit('key', 8, 1); ``` -### close ------ -_**Description**_: Disconnects from the Redis instance. - -*Note*: Closing a persistent connection requires PhpRedis >= 4.2.0. - -##### *Parameters* -None. - -##### *Return value* -*BOOL*: `TRUE` on success, `FALSE` on failure. - -### setOption ------ -_**Description**_: Set client option. - -##### *Parameters* -*parameter name* -*parameter value* - -##### *Return value* -*BOOL*: `TRUE` on success, `FALSE` on error. +### [Connection](docs/content/connection.md) -##### *Example* ```php -$redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_NONE); // Don't serialize data -$redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP); // Use built-in serialize/unserialize -$redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_IGBINARY); // Use igBinary serialize/unserialize -$redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_MSGPACK); // Use msgpack serialize/unserialize -$redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_JSON); // Use JSON to serialize/unserialize - -$redis->setOption(Redis::OPT_PREFIX, 'myAppName:'); // use custom prefix on all keys - -/* Options for the SCAN family of commands, indicating whether to abstract - empty results from the user. If set to SCAN_NORETRY (the default), phpredis - will just issue one SCAN command at a time, sometimes returning an empty - array of results. If set to SCAN_RETRY, phpredis will retry the scan command - until keys come back OR Redis returns an iterator of zero -*/ -$redis->setOption(Redis::OPT_SCAN, Redis::SCAN_NORETRY); -$redis->setOption(Redis::OPT_SCAN, Redis::SCAN_RETRY); - -/* Scan can also be configured to automatically prepend the currently set PhpRedis - prefix to any MATCH pattern. */ -$redis->setOption(Redis::OPT_SCAN, Redis::SCAN_PREFIX); -$redis->setOption(Redis::OPT_SCAN, Redis::SCAN_NOPREFIX); +$valkey = new Valkey(); +$valkey->connect('127.0.0.1', 6379); +$valkey->open('127.0.0.1', 6379); +$valkey->pconnect('127.0.0.1', 6379); +$valkey->popen('127.0.0.1', 6379); +$valkey->auth('secret'); +$valkey->select(1); +$valkey->swapdb(0, 1); +$valkey->close(); +$valkey->setOption(Valkey::OPT_PREFIX, 'redis:'); +$valkey->getOption(Valkey::OPT_PREFIX) +$valkey->ping('pong'); +$valkey->echo('redis'); ``` +### [Geospatial Indexes](docs/content/geospatial.md) -### getOption ------ -_**Description**_: Get client option. - -##### *Parameters* -*parameter name* - -##### *Return value* -Parameter value. - -##### *Example* ```php -// return Redis::SERIALIZER_NONE, Redis::SERIALIZER_PHP, -// Redis::SERIALIZER_IGBINARY, Redis::SERIALIZER_MSGPACK or Redis::SERIALIZER_JSON -$redis->getOption(Redis::OPT_SERIALIZER); +$valkey = new Valkey(); +$valkey->connect('127.0.0.1', 6379); +$options = ['WITHDIST']; +$valkey->geoAdd('Geocoding', -122.431, 37.773, 'San Francisco'); +$valkey->geoAdd('Geocoding', -73.935242, 40.730610, 'New York'); +$valkey->geoHash('Geocoding', 'San Francisco'); +$valkey->geoPos('Geocoding', 'San Francisco'); +$valkey->geoDist('Geocoding', 'San Francisco', 'New York'); +$valkey->geoRadius("Geocoding", -157.858, 21.306, 300, 'mi', $options); +$valkey->geoRadiusByMember("Geocoding", 'San Francisco', 300, 'mi', $options); ``` -### ping ------ -_**Description**_: Check the current connection status. +### [Hashes](docs/content/hashes.md) -##### *Prototype* ```php -$redis->ping([string $message]); +$valkey = new Valkey(); +$valkey->connect('127.0.0.1', 6379); +$valkey->hSet('hash', 'key1', 'hello'); /* 1, 'key1' => 'hello' in the hash at "h" */ +$valkey->hGet('hash', 'key1'); /* returns "hello" */ +$valkey->hSetNx('hash', 'key1', 'hello'); /* TRUE, 'key1' => 'hello' in the hash at "hash" */ +$valkey->hLen('hash'); /* returns 2 */ +$valkey->hGetAll('hash'); +$valkey->hKeys('hash'); +$valkey->hVals('hash'); ``` -##### *Return value* -*Mixed*: This method returns `TRUE` on success, or the passed string if called with an argument. +### [HyperLogLogs](docs/content/hyperloglogs.md) -##### *Example* ```php -/* When called without an argument, PING returns `TRUE` */ -$redis->ping(); - -/* If passed an argument, that argument is returned. Here 'hello' will be returned */ -$redis->ping('hello'); +$valkey->pfAdd('HyperLogLog', ['a', 'b', 'c']); +$valkey->pfCount('HyperLogLog'); // 3 +$valkey->pfAdd('HyperLogLog2', ['b', 'd']); +$valkey->pfMerge('HyperLogLogMerged', ['HyperLogLog', 'HyperLogLog2']); +$valkey->pfCount('HyperLogLogMerged'); // 4 => a, b, c, d ``` -*Note*: Prior to PhpRedis 5.0.0 this command simply returned the string `+PONG`. - -### echo ------ -_**Description**_: Sends a string to Redis, which replies with the same string - -##### *Parameters* - -*STRING*: The message to send. - -##### *Return value* - -*STRING*: the same message. - -## Retry and backoff - -1. [Maximum retries](#maximum-retries) -1. [Backoff algorithms](#backoff-algorithms) - -### Maximum retries -You can set and get the maximum retries upon connection issues using the `OPT_MAX_RETRIES` option. Note that this is the number of _retries_, meaning if you set this option to _n_, there will be a maximum _n+1_ attempts overall. Defaults to 10. - -##### *Example* +### [Introspection](docs/content/introspection.md) ```php -$redis->setOption(Redis::OPT_MAX_RETRIES, 5); -$redis->getOption(Redis::OPT_MAX_RETRIES); +$valkey = new Valkey(); +$valkey->connect('127.0.0.1', 6379); +$valkey->isConnected(); +$valkey->getHost(); +$valkey->getPort(); +$valkey->getDbNum(); +$valkey->getTimeout(); +$valkey->getReadTimeout(); +$valkey->getPersistentID(); +$valkey->getAuth(); ``` -### Backoff algorithms -You can set the backoff algorithm using the `Redis::OPT_BACKOFF_ALGORITHM` option and choose among the following algorithms described in this blog post by Marc Brooker from AWS: [Exponential Backoff And Jitter](https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter): - -* Default: `Redis::BACKOFF_ALGORITHM_DEFAULT` -* Decorrelated jitter: `Redis::BACKOFF_ALGORITHM_DECORRELATED_JITTER` -* Full jitter: `Redis::BACKOFF_ALGORITHM_FULL_JITTER` -* Equal jitter: `Redis::BACKOFF_ALGORITHM_EQUAL_JITTER` -* Exponential: `Redis::BACKOFF_ALGORITHM_EXPONENTIAL` -* Uniform: `Redis::BACKOFF_ALGORITHM_UNIFORM` -* Constant: `Redis::BACKOFF_ALGORITHM_CONSTANT` - -These algorithms depend on the _base_ and _cap_ parameters, both in milliseconds, which you can set using the `Redis::OPT_BACKOFF_BASE` and `Redis::OPT_BACKOFF_CAP` options, respectively. - -##### *Example* +### [Keys](docs/content/keys.md) ```php -$redis->setOption(Redis::OPT_BACKOFF_ALGORITHM, Redis::BACKOFF_ALGORITHM_DECORRELATED_JITTER); -$redis->setOption(Redis::OPT_BACKOFF_BASE, 500); // base for backoff computation: 500ms -$redis->setOption(Redis::OPT_BACKOFF_CAP, 750); // backoff time capped at 750ms -``` - -## Server - -1. [acl](#acl) - Manage Redis ACLs -1. [bgRewriteAOF](#bgrewriteaof) - Asynchronously rewrite the append-only file -1. [bgSave](#bgsave) - Asynchronously save the dataset to disk (in background) -1. [config](#config) - Get or Set the Redis server configuration parameters -1. [dbSize](#dbsize) - Return the number of keys in selected database -1. [flushAll](#flushall) - Remove all keys from all databases -1. [flushDb](#flushdb) - Remove all keys from the current database -1. [info](#info) - Get information and statistics about the server -1. [lastSave](#lastsave) - Get the timestamp of the last disk save -1. [save](#save) - Synchronously save the dataset to disk (wait to complete) -1. [slaveOf](#slaveof) - Make the server a slave of another instance, or promote it to master -1. [time](#time) - Return the current server time -1. [slowLog](#slowlog) - Access the Redis slowLog entries - -### acl ------ -_**Description**_: Execute the Redis ACL command. - -##### *Parameters* -_variable_: Minimum of one argument for `Redis` and two for `RedisCluster`. +$valkey = new Valkey(); +$valkey->connect('127.0.0.1', 6379); +$valkey->del('key'); +$valkey->delete('key'); +$valkey->unlink('key'); +$valkey->dump('key'); +$valkey->exists('key'); +$valkey->expire('key', 123); +$valkey->expireAt('key', 1743016214.623306); +$valkey->keys(); +$valkey->scan(); +$valkey->migrate('key'); +$valkey->move('key'); +$valkey->object('key'); +$valkey->persist('key'); +$valkey->randomKey('key'); +$valkey->rename('key', 'yek'); +$valkey->renameNx('key', 'yek'); +$valkey->type('key'); +$valkey->sort('key'); +$valkey->ttl('key'); +$valkey->restore('key'); +``` + +### [Lists](docs/content/lists.md) -##### *Example* ```php -$redis->acl('USERS'); /* Get a list of users */ -$redis->acl('LOG'); /* See log of Redis' ACL subsystem */ +$valkey = new Valkey(); +$valkey->connect('127.0.0.1', 6379); +/* Non blocking feature */ +$valkey->lPush('key1', 'A'); +$valkey->del('key2'); +$valkey->blPop('key1', 'key2', 10); /* ['key1', 'A'] */ +$valkey->rPush('key1', 'A'); +$valkey->lInsert('key1', Valkey::AFTER, 'A', 'X'); /* 0 */ +$valkey->lRange('key1', 0, -1); /* ['A', 'B', 'X', 'C'] */ ``` -*Note*: In order to user the `ACL` command you must be communicating with Redis >= 6.0 and be logged into an account that has access to administration commands such as ACL. Please reference [this tutorial](https://redis.io/topics/acl) for an overview of Redis 6 ACLs and [the redis command reference](https://redis.io/commands) for every ACL subcommand. - -*Note*: If you are connecting to Redis server >= 4.0.0 you can remove a key with the `unlink` method in the exact same way you would use `del`. The Redis [unlink](https://redis.io/commands/unlink) command is non-blocking and will perform the actual deletion asynchronously. - -### bgRewriteAOF ------ -_**Description**_: Start the background rewrite of AOF (Append-Only File) +### [Pub/sub](docs/content/pubsub.md) -##### *Parameters* -None. - -##### *Return value* -*BOOL*: `TRUE` in case of success, `FALSE` in case of failure. - -##### *Example* ```php -$redis->bgRewriteAOF(); +$valkey = new Valkey(); +$valkey->connect('127.0.0.1', 6379); +/* Non blocking feature */ +$valkey->lPush('key1', 'A'); +$valkey->del('key2'); +$valkey->blPop('key1', 'key2', 10); /* ['key1', 'A'] */ +$valkey->rPush('key1', 'A'); +$valkey->lInsert('key1', Valkey::AFTER, 'A', 'X'); /* 0 */ +$valkey->lRange('key1', 0, -1); /* ['A', 'B', 'X', 'C'] */ ``` -### bgSave ------ -_**Description**_: Asynchronously save the dataset to disk (in background) - -##### *Parameters* -None. +### [Scripting](docs/content/scripting.md) -##### *Return value* -*BOOL*: `TRUE` in case of success, `FALSE` in case of failure. If a save is already running, this command will fail and return `FALSE`. - -##### *Example* ```php -$redis->bgSave(); +$valkey = new Valkey(); +$valkey->connect('127.0.0.1', 6379); +$valkey->eval("return 1"); // Returns an integer: 1 +$valkey->eval("return {1,2,3}"); // Returns [1,2,3] +$valkey->del('mylist'); +$valkey->rpush('mylist','a'); +$valkey->rpush('mylist','b'); +$valkey->rpush('mylist','c'); +// Nested response: [1,2,3,['a','b','c']]; +$valkey->eval("return {1,2,3,redis.call('lrange','mylist',0,-1)}"); ``` -### config ------ -_**Description**_: Get or Set the Redis server configuration parameters. +### [Sets](docs/content/sets.md) -##### *Prototype* ```php -$redis->config(string $operation, string|array|null $key = NULL, ?string $value = NULL): mixed; +$valkey = new Valkey(); +$valkey->connect('127.0.0.1', 6379); +$valkey->sAdd('key1' , 'member1'); +$valkey->sAdd('key1' , 'member2'); +$valkey->sAdd('key1' , 'member3'); /* 'key1' => {'member1', 'member2', 'member3'}*/ +$valkey->sCard('key1'); /* 3 */ +$valkey->sIsMember('key1', 'member1'); /* TRUE */ +$valkey->sIsMember('key1', 'memberX'); /* FALSE */ ``` -##### *Return value* -*Associative array* for `GET`, key(s) -> value(s) -*bool* for `SET`, `RESETSTAT`, and `REWRITE` +### [Sorted Sets](docs/content/sorted-sets.md) -##### *Examples* ```php -$redis->config("GET", "*max-*-entries*"); -$redis->config("SET", ['timeout', 'loglevel']); -$redis->config("SET", "dir", "/var/run/redis/dumps/"); -$redis->config("SET", ['timeout' => 128, 'loglevel' => 'warning']); -$redis->config('RESETSTAT'); +$valkey = new Valkey(); +$valkey->connect('127.0.0.1', 6379); +$valkey->zAdd('key', 1, 'val1'); +$valkey->zAdd('key', 0, 'val0'); +$valkey->zAdd('key', 5, 'val5'); +$valkey->zRange('key', 0, -1); // [val0, val1, val5] +// From Valkey 3.0.2 it's possible to add options like XX, NX, CH, INCR +$valkey->zAdd('key', ['CH'], 5, 'val5', 10, 'val10', 15, 'val15'); ``` -### dbSize ------ -_**Description**_: Return the number of keys in selected database. - -##### *Parameters* -None. - -##### *Return value* -*INTEGER*: DB size, in number of keys. +### [Streams](docs/content/streams.md) -##### *Example* ```php -$count = $redis->dbSize(); -echo "Redis has $count keys\n"; +$valkey = new Valkey(); +$valkey->connect('127.0.0.1', 6379); +$obj_redis->xAdd('mystream', "*", ['field' => 'value']); +$obj_redis->xAdd('mystream', "*", ['field' => 'value'], 1000); // set max length of stream to 1000 +$obj_redis->xAdd('mystream', "*", ['field' => 'value'], 1000, true); // set max length of stream to ~1000 +$obj_redis->xAck('mystream', 'group1', ['1530063064286-0', '1530063064286-1']); +/* Get everything in this stream */ +$obj_redis->xRange('mystream', '-', '+'); +/* Only the first two messages */ +$obj_redis->xRange('mystream', '-', '+', 2); +$obj_redis->xInfo('STREAM', 'mystream', 'FULL', 10); +$obj_redis->xRead(['stream1' => '1535222584555-0', 'stream2' => '1535222584555-0']); +$obj_redis->xDel('mystream', ['1530115304877-0', '1530115305731-0']); ``` -### flushAll ------ -_**Description**_: Remove all keys from all databases. +### [Strings](docs/content/strings.md) -##### *Parameters* -*async* (bool) requires server version 4.0.0 or greater - -##### *Return value* -*BOOL*: Always `TRUE`. - -##### *Example* ```php -$redis->flushAll(); +$valkey = new Valkey(); +$valkey->connect('127.0.0.1', 6379); +// Simple key -> value set +$valkey->set('key', 'value'); +// Will redirect, and actually make an SETEX call +$valkey->set('key', 'value', 10); +// Will set the key, if it doesn't exist, with a ttl of 10 seconds +$valkey->set('key:'.time(), 'value', ['nx', 'ex' => 10]); +// Will set a key, if it does exist, with a ttl of 1000 miliseconds +$valkey->set('key', 'value', ['xx', 'px' => 1000]); +$valkey->setEx('key', 10, 'value1'); +$valkey->append('key', 'value2'); /* 12 */ +$valkey->get('key'); /* 'value1value2' */ +$valkey->exists('key'); /* 1 */ +$valkey->exists('NonExistingKey'); /* 0 */ +$valkey->mset(['foo' => 'foo', 'bar' => 'bar', 'baz' => 'baz']); +$valkey->exists(['foo', 'bar', 'baz']); /* 3 */ ``` -### flushDb ------ -_**Description**_: Remove all keys from the current database. +### [Transactions](docs/content/transactions.md) -##### *Prototype* ```php -$redis->flushdb(?bool $sync = NULL): Redis|bool; +$valkey = new Valkey(); +$valkey->connect('127.0.0.1', 6379); +$ret = $valkey->multi() + ->set('key1', 'val1') + ->get('key1') + ->set('key2', 'val2') + ->get('key2') + ->exec(); ``` -##### *Return value* -*BOOL*: This command returns true on success and false on failure. +## Contributing -##### *Example* -```php -$redis->flushDb(); -``` +We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to get started. -### info ------ -_**Description**_: Get information and statistics about the server +### License -Returns an associative array that provides information about the server. Passing no arguments to -INFO will call the standard REDIS INFO command, which returns information such as the following: +Valkey-PHP is open-sourced software licensed under the BSD-3-Clause license. -* redis_version -* arch_bits -* uptime_in_seconds -* uptime_in_days -* connected_clients -* connected_slaves -* used_memory -* changes_since_last_save -* bgsave_in_progress -* last_save_time -* total_connections_received -* total_commands_processed -* role +## Credits -You can pass a variety of options to INFO ([per the Redis documentation](http://redis.io/commands/info)), -which will modify what is returned. +- [Roberto Luna Rojas](https://github.com/rlunar) +- [Adrian Luna Rojas](https://github.com/adrianluna) +- [All Contributors](../../contributors) -##### *Parameters* -*option*: The option to provide redis (e.g. "COMMANDSTATS", "CPU") +### Acknowledgements -##### *Example* -```php -$redis->info(); /* standard redis INFO command */ -$redis->info("COMMANDSTATS"); /* Information on the commands that have been run (>=2.6 only) -$redis->info("CPU"); /* just CPU information from Redis INFO */ -``` +This project builds upon the excellent work of: -### lastSave ------ -_**Description**_: Returns the timestamp of the last disk save. +- [phpredis/phpredis](https://github.com/phpredis/phpredis) +- [webdcg/redis](https://github.com/webdcg/redis) -##### *Parameters* -None. +We thank all the contributors to these projects for their valuable work. -##### *Return value* -*INT*: timestamp. +## Support -##### *Example* -```php -$redis->lastSave(); -``` - -### save ------ -_**Description**_: Synchronously save the dataset to disk (wait to complete) - -##### *Parameters* -None. - -##### *Return value* -*BOOL*: `TRUE` in case of success, `FALSE` in case of failure. If a save is already running, this command will fail and return `FALSE`. - -##### *Example* -```php -$redis->save(); -``` - -### slaveOf ------ -_**Description**_: Changes the slave status - -##### *Parameters* -Either host (string) and port (int), or no parameter to stop being a slave. - -##### *Return value* -*BOOL*: `TRUE` in case of success, `FALSE` in case of failure. - -##### *Example* -```php -$redis->slaveOf('10.0.1.7', 6379); -/* ... */ -$redis->slaveOf(); -``` - -### time ------ -_**Description**_: Return the current server time. - -##### *Parameters* -(none) - -##### *Return value* -If successful, the time will come back as an associative array with element zero being -the unix timestamp, and element one being microseconds. - -##### *Examples* -```php -$redis->time(); -``` - -### slowLog ------ -_**Description**_: Access the Redis slowLog - -##### *Parameters* -*Operation* (string): This can be either `GET`, `LEN`, or `RESET` -*Length* (integer), optional: If executing a `SLOWLOG GET` command, you can pass an optional length. -##### - -##### *Return value* -The return value of SLOWLOG will depend on which operation was performed. -SLOWLOG GET: Array of slowLog entries, as provided by Redis -SLOGLOG LEN: Integer, the length of the slowLog -SLOWLOG RESET: Boolean, depending on success -##### - -##### *Examples* -```php -// Get ten slowLog entries -$redis->slowLog('get', 10); -// Get the default number of slowLog entries - -$redis->slowLog('get'); -// Reset our slowLog -$redis->slowLog('reset'); - -// Retrieve slowLog length -$redis->slowLog('len'); -``` - -## Keys and Strings - -### Strings ------ - -* [append](#append) - Append a value to a key -* [bitCount](#bitcount) - Count set bits in a string -* [bitOp](#bitop) - Perform bitwise operations between strings -* [decr, decrBy](#decr-decrby) - Decrement the value of a key -* [get](#get) - Get the value of a key -* [getEx](#getex) - Get the value of a key and set its expiration -* [getBit](#getbit) - Returns the bit value at offset in the string value stored at key -* [getRange](#getrange) - Get a substring of the string stored at a key -* [getSet](#getset) - Set the string value of a key and return its old value -* [incr, incrBy](#incr-incrby) - Increment the value of a key -* [incrByFloat](#incrbyfloat) - Increment the float value of a key by the given amount -* [mGet](#mget) - Get the values of all the given keys -* [mSet, mSetNX](#mset-msetnx) - Set multiple keys to multiple values -* [set](#set) - Set the string value of a key -* [setBit](#setbit) - Sets or clears the bit at offset in the string value stored at key -* [setEx, pSetEx](#setex-psetex) - Set the value and expiration of a key -* [setNx](#setnx) - Set the value of a key, only if the key does not exist -* [setRange](#setrange) - Overwrite part of a string at key starting at the specified offset -* [strLen](#strlen) - Get the length of the value stored in a key - -### Keys ------ - -* [del, delete, unlink](#del-delete-unlink) - Delete a key -* [dump](#dump) - Return a serialized version of the value stored at the specified key. -* [exists](#exists) - Determine if a key exists -* [expire, pexpire](#expire-pexpire) - Set a key's time to live in seconds -* [expireAt, pexpireAt](#expireat-pexpireat) - Set the expiration for a key as a UNIX timestamp -* [keys](#keys) - Find all keys matching the given pattern -* [scan](#scan) - Scan for keys in the keyspace (Redis >= 2.8.0) -* [migrate](#migrate) - Atomically transfer a key from a Redis instance to another one -* [move](#move) - Move a key to another database -* [object](#object) - Inspect the internals of Redis objects -* [persist](#persist) - Remove the expiration from a key -* [randomKey](#randomkey) - Return a random key from the keyspace -* [rename](#rename) - Rename a key -* [renameNx](#renamenx) - Rename a key, only if the new key does not exist -* [type](#type) - Determine the type stored at key -* [sort](#sort) - Sort the elements in a list, set or sorted set -* [ttl, pttl](#ttl-pttl) - Get the time to live for a key -* [restore](#restore) - Create a key using the provided serialized value, previously obtained with [dump](#dump). - ------ - -### get ------ -_**Description**_: Get the value related to the specified key - -##### *Parameters* -*key* - -##### *Return value* -*String* or *Bool*: If key didn't exist, `FALSE` is returned. Otherwise, the value related to this key is returned. - -##### *Examples* - -```php -$redis->get('key'); -``` - -### getEx ------ -_**Description**_: Get the value related to the specified key and set its expiration - -##### *Parameters* -*key* -*options array* (optional) with the following keys: - * `EX` - expire time in seconds - * `PX` - expire time in milliseconds - * `EXAT` - expire time in seconds since UNIX epoch - * `PXAT` - expire time in milliseconds since UNIX epoch - * `PERSIST` - remove the expiration from the key - -##### *Return value* -*String* or *Bool*: If key didn't exist, `FALSE` is returned. Otherwise, the value related to this key is returned. - -##### *Examples* - -```php -$redis->getEx('key', ['EX' => 10]); // get key and set its expiration to 10 seconds -``` - -### set ------ -_**Description**_: Set the string value in argument as value of the key. If you're using Redis >= 2.6.12, you can pass extended options as explained below - -##### *Parameters* -*Key* -*Value* -*Timeout or Options Array* (optional). If you pass an integer, phpredis will redirect to SETEX, and will try to use Redis >= 2.6.12 extended options if you pass an array with valid values - -##### *Return value* -*Bool* `TRUE` if the command is successful. - -##### *Examples* -```php -// Simple key -> value set -$redis->set('key', 'value'); - -// Will redirect, and actually make an SETEX call -$redis->set('key','value', 10); - -// Will set the key, if it doesn't exist, with a ttl of 10 seconds -$redis->set('key', 'value', ['nx', 'ex'=>10]); - -// Will set a key, if it does exist, with a ttl of 1000 milliseconds -$redis->set('key', 'value', ['xx', 'px'=>1000]); - -``` - -### setEx, pSetEx ------ -_**Description**_: Set the string value in argument as value of the key, with a time to live. PSETEX uses a TTL in milliseconds. - -##### *Parameters* -*Key* -*TTL* -*Value* - -##### *Return value* -*Bool* `TRUE` if the command is successful. - -##### *Examples* - -```php -$redis->setEx('key', 3600, 'value'); // sets key → value, with 1h TTL. -$redis->pSetEx('key', 100, 'value'); // sets key → value, with 0.1 sec TTL. -``` - -### setNx ------ -_**Description**_: Set the string value in argument as value of the key if the key doesn't already exist in the database. - -##### *Parameters* -*key* -*value* - -##### *Return value* -*Bool* `TRUE` in case of success, `FALSE` in case of failure. - -##### *Examples* -```php -$redis->setNx('key', 'value'); /* return TRUE */ -$redis->setNx('key', 'value'); /* return FALSE */ -``` - -### del, delete, unlink ------ -_**Description**_: Remove specified keys. - -##### *Parameters* -An array of keys, or an undefined number of parameters, each a key: *key1* *key2* *key3* ... *keyN* - -*Note*: If you are connecting to Redis server >= 4.0.0 you can remove a key with the `unlink` method in the exact same way you would use `del`. The Redis [unlink](https://redis.io/commands/unlink) command is non-blocking and will perform the actual deletion asynchronously. - -##### *Return value* -*Long* Number of keys deleted. - -##### *Examples* -```php -$redis->set('key1', 'val1'); -$redis->set('key2', 'val2'); -$redis->set('key3', 'val3'); -$redis->set('key4', 'val4'); - -$redis->del('key1', 'key2'); /* return 2 */ -$redis->del(['key3', 'key4']); /* return 2 */ - -/* If using Redis >= 4.0.0 you can call unlink */ -$redis->unlink('key1', 'key2'); -$redis->unlink(['key1', 'key2']); -``` - -**Note:** `delete` is an alias for `del` and will be removed in future versions of phpredis. - -### exists ------ -_**Description**_: Verify if the specified key exists. - -##### *Parameters* -*key* - -##### *Return value* -*long*: The number of keys tested that do exist. - -##### *Examples* -```php -$redis->set('key', 'value'); -$redis->exists('key'); /* 1 */ -$redis->exists('NonExistingKey'); /* 0 */ - -$redis->mset(['foo' => 'foo', 'bar' => 'bar', 'baz' => 'baz']); -$redis->exists(['foo', 'bar', 'baz']); /* 3 */ -$redis->exists('foo', 'bar', 'baz'); /* 3 */ -``` - -**Note**: This function took a single argument and returned TRUE or FALSE in phpredis versions < 4.0.0. - -### incr, incrBy ------ -_**Description**_: Increment the number stored at key by one. If the second argument is filled, it will be used as the integer value of the increment. - -##### *Parameters* -*key* -*value*: value that will be added to key (only for incrBy) - -##### *Return value* -*INT* the new value - -##### *Examples* -```php -$redis->incr('key1'); /* key1 didn't exists, set to 0 before the increment */ - /* and now has the value 1 */ - -$redis->incr('key1'); /* 2 */ -$redis->incr('key1'); /* 3 */ -$redis->incr('key1'); /* 4 */ - -// Will redirect, and actually make an INCRBY call -$redis->incr('key1', 10); /* 14 */ - -$redis->incrBy('key1', 10); /* 24 */ -``` - -### incrByFloat ------ -_**Description**_: Increment the key with floating point precision. - -##### *Parameters* -*key* -*value*: (float) value that will be added to the key - -##### *Return value* -*FLOAT* the new value - -##### *Examples* -```php -$redis->incrByFloat('key1', 1.5); /* key1 didn't exist, so it will now be 1.5 */ - - -$redis->incrByFloat('key1', 1.5); /* 3 */ -$redis->incrByFloat('key1', -1.5); /* 1.5 */ -$redis->incrByFloat('key1', 2.5); /* 4 */ -``` - -### decr, decrBy ------ -_**Description**_: Decrement the number stored at key by one. If the second argument is filled, it will be used as the integer value of the decrement. - -##### *Parameters* -*key* -*value*: value that will be subtracted to key (only for decrBy) - -##### *Return value* -*INT* the new value - -##### *Examples* -```php -$redis->decr('key1'); /* key1 didn't exists, set to 0 before the increment */ - /* and now has the value -1 */ - -$redis->decr('key1'); /* -2 */ -$redis->decr('key1'); /* -3 */ - -// Will redirect, and actually make an DECRBY call -$redis->decr('key1', 10); /* -13 */ - -$redis->decrBy('key1', 10); /* -23 */ -``` - -### mGet ------ -_**Description**_: Get the values of all the specified keys. If one or more keys don't exist, the array will contain `FALSE` at the position of the key. - -##### *Parameters* -*Array*: Array containing the list of the keys - -##### *Return value* -*Array*: Array containing the values related to keys in argument - -##### *Examples* -```php -$redis->set('key1', 'value1'); -$redis->set('key2', 'value2'); -$redis->set('key3', 'value3'); -$redis->mGet(['key1', 'key2', 'key3']); /* ['value1', 'value2', 'value3']; -$redis->mGet(['key0', 'key1', 'key5']); /* [`FALSE`, 'value1', `FALSE`]; -``` - -### getSet ------ -_**Description**_: Sets a value and returns the previous entry at that key. -##### *Parameters* -*Key*: key - -*STRING*: value - -##### *Return value* -A string, the previous value located at this key. -##### *Example* -```php -$redis->set('x', '42'); -$exValue = $redis->getSet('x', 'lol'); // return '42', replaces x by 'lol' -$newValue = $redis->get('x')' // return 'lol' -``` - -### randomKey ------ -_**Description**_: Returns a random key. - -##### *Parameters* -None. -##### *Return value* -*STRING*: an existing key in redis. - -##### *Example* -```php -$key = $redis->randomKey(); -$surprise = $redis->get($key); // who knows what's in there. -``` - -### move ------ -_**Description**_: Moves a key to a different database. - -##### *Parameters* -*Key*: key, the key to move. - -*INTEGER*: dbindex, the database number to move the key to. - -##### *Return value* -*BOOL*: `TRUE` in case of success, `FALSE` in case of failure. -##### *Example* - -```php -$redis->select(0); // switch to DB 0 -$redis->set('x', '42'); // write 42 to x -$redis->move('x', 1); // move to DB 1 -$redis->select(1); // switch to DB 1 -$redis->get('x'); // will return 42 -``` - -### rename ------ -_**Description**_: Renames a key. -##### *Parameters* -*STRING*: srckey, the key to rename. - -*STRING*: dstkey, the new name for the key. - -##### *Return value* -*BOOL*: `TRUE` in case of success, `FALSE` in case of failure. -##### *Example* -```php -$redis->set('x', '42'); -$redis->rename('x', 'y'); -$redis->get('y'); // → 42 -$redis->get('x'); // → `FALSE` -``` - -### renameNx ------ -_**Description**_: Same as rename, but will not replace a key if the destination already exists. This is the same behaviour as setNx. - -### expire, pexpire ------ -_**Description**_: Sets an expiration on a key in either seconds or milliseconds. - -##### *Prototype* -```php -public function expire(string $key, int $seconds, ?string $mode = NULL): Redis|bool; -public function pexpire(string $key, int $milliseconds, ?string $mode = NULL): Redis|bool; -``` - -##### *Return value* -*BOOL*: `TRUE` if an expiration was set, and `FALSE` on failure or if one was not set. You can distinguish between an error and an expiration not being set by checking `getLastError()`. -##### *Example* -```php -$redis->set('x', '42'); -$redis->expire('x', 3); // x will disappear in 3 seconds. -sleep(5); // wait 5 seconds -$redis->get('x'); // will return `FALSE`, as 'x' has expired. -``` - -### expireAt, pexpireAt ------ -_**Description**_: Seta specific timestamp for a key to expire in seconds or milliseconds. - -##### *Prototype* -```php -public function expireat(string $key, int $unix_timestamp, ?string $mode = NULL): Redis|bool; -public function pexpireat(string $key, int $unix_timestamp_millis, ?string $mode = NULL): Redis|bool; -``` - -##### *Return value* -*BOOL*: `TRUE` if an expiration was set and `FALSE` if one was not set or in the event on an error. You can detect an actual error by checking `getLastError()`. - -##### *Example* -```php -$redis->set('x', '42'); -$redis->expireAt('x', time(NULL) + 3); // x will disappear in 3 seconds. -sleep(5); // wait 5 seconds -$redis->get('x'); // will return `FALSE`, as 'x' has expired. -``` - -### keys ------ -_**Description**_: Returns the keys that match a certain pattern. - -##### *Parameters* -*STRING*: pattern, using '*' as a wildcard. - -##### *Return value* -*Array of STRING*: The keys that match a certain pattern. - -##### *Example* -```php -$allKeys = $redis->keys('*'); // all keys will match this. -$keyWithUserPrefix = $redis->keys('user*'); -``` - -### scan ------ -_**Description**_: Scan the keyspace for keys - -##### *Parameters* -*LONG (reference)*: Iterator, initialized to NULL -*STRING, Optional*: Pattern to match -*LONG, Optional*: Count of keys per iteration (only a suggestion to Redis) - -##### *Return value* -*Array, boolean*: This function will return an array of keys or FALSE if Redis returned zero keys - -*Note*: SCAN is a "directed node" command in [RedisCluster](cluster.md#directed-node-commands) - -##### *Example* -```php - -/* Without enabling Redis::SCAN_RETRY (default condition) */ -$it = NULL; -do { - // Scan for some keys - $arr_keys = $redis->scan($it); - - // Redis may return empty results, so protect against that - if ($arr_keys !== FALSE) { - foreach($arr_keys as $str_key) { - echo "Here is a key: $str_key\n"; - } - } -} while ($it > 0); -echo "No more keys to scan!\n"; - -/* With Redis::SCAN_RETRY enabled */ -$redis->setOption(Redis::OPT_SCAN, Redis::SCAN_RETRY); -$it = NULL; - -/* phpredis will retry the SCAN command if empty results are returned from the - server, so no empty results check is required. */ -while ($arr_keys = $redis->scan($it)) { - foreach ($arr_keys as $str_key) { - echo "Here is a key: $str_key\n"; - } -} -echo "No more keys to scan!\n"; -``` - -### object ------ -_**Description**_: Describes the object pointed to by a key. - -##### *Parameters* -The information to retrieve (string) and the key (string). Info can be one of the following: - -* "encoding" -* "refcount" -* "idletime" - -##### *Return value* -*STRING* for "encoding", *LONG* for "refcount" and "idletime", `FALSE` if the key doesn't exist. - -##### *Example* -```php -$redis->object("encoding", "l"); // → ziplist -$redis->object("refcount", "l"); // → 1 -$redis->object("idletime", "l"); // → 400 (in seconds, with a precision of 10 seconds). -``` - -### type ------ -_**Description**_: Returns the type of data pointed by a given key. - -##### *Parameters* -*Key*: key - -##### *Return value* - -Depending on the type of the data pointed by the key, this method will return the following value: -string: Redis::REDIS_STRING -set: Redis::REDIS_SET -list: Redis::REDIS_LIST -zset: Redis::REDIS_ZSET -hash: Redis::REDIS_HASH -other: Redis::REDIS_NOT_FOUND - -##### *Example* -```php -$redis->type('key'); -``` - -### append ------ -_**Description**_: Append specified string to the string stored in specified key. - -##### *Parameters* -*Key* -*Value* - -##### *Return value* -*INTEGER*: Size of the value after the append - -##### *Example* -```php -$redis->set('key', 'value1'); -$redis->append('key', 'value2'); /* 12 */ -$redis->get('key'); /* 'value1value2' */ -``` - -### getRange ------ -_**Description**_: Return a substring of a larger string - -##### *Parameters* -*key* -*start* -*end* - -##### *Return value* -*STRING*: the substring - -##### *Example* -```php -$redis->set('key', 'string value'); -$redis->getRange('key', 0, 5); /* 'string' */ -$redis->getRange('key', -5, -1); /* 'value' */ -``` - -### setRange ------ -_**Description**_: Changes a substring of a larger string. - -##### *Parameters* -*key* -*offset* -*value* - -##### *Return value* -*STRING*: the length of the string after it was modified. - -##### *Example* -```php -$redis->set('key', 'Hello world'); -$redis->setRange('key', 6, "redis"); /* returns 11 */ -$redis->get('key'); /* "Hello redis" */ -``` - -### strLen ------ -_**Description**_: Get the length of a string value. - -##### *Parameters* -*key* - -##### *Return value* -*INTEGER* - -##### *Example* -```php -$redis->set('key', 'value'); -$redis->strlen('key'); /* 5 */ -``` - -### getBit ------ -_**Description**_: Return a single bit out of a larger string - -##### *Parameters* -*key* -*offset* - -##### *Return value* -*LONG*: the bit value (0 or 1) - -##### *Example* -```php -$redis->set('key', "\x7f"); // this is 0111 1111 -$redis->getBit('key', 0); /* 0 */ -$redis->getBit('key', 1); /* 1 */ -``` - -### setBit ------ -_**Description**_: Changes a single bit of a string. - -##### *Parameters* -*key* -*offset* -*value*: bool or int (1 or 0) - -##### *Return value* -*LONG*: 0 or 1, the value of the bit before it was set. - -##### *Example* -```php -$redis->set('key', "*"); // ord("*") = 42 = 0x2f = "0010 1010" -$redis->setBit('key', 5, 1); /* returns 0 */ -$redis->setBit('key', 7, 1); /* returns 0 */ -$redis->get('key'); /* chr(0x2f) = "/" = b("0010 1111") */ -``` - -### bitOp ------ -_**Description**_: Bitwise operation on multiple keys. - -##### *Parameters* -*operation*: either "AND", "OR", "NOT", "XOR" -*ret_key*: return key -*key1* -*key2...* - -##### *Return value* -*LONG*: The size of the string stored in the destination key. - -### bitCount ------ -_**Description**_: Count bits in a string. - -##### *Parameters* -*key* - -##### *Return value* -*LONG*: The number of bits set to 1 in the value behind the input key. - -### sort ------ -_**Description**_: Sort the elements in a list, set or sorted set. - -##### *Parameters* -*Key*: key -*Options*: [key => value, ...] - optional, with the following keys and values: -``` - 'by' => 'some_pattern_*', - 'limit' => [0, 1], - 'get' => 'some_other_pattern_*' or an array of patterns, - 'sort' => 'asc' or 'desc', - 'alpha' => TRUE, - 'store' => 'external-key' -``` -##### *Return value* -An array of values, or a number corresponding to the number of elements stored if that was used. - -##### *Example* -```php -$redis->del('s'); -$redis->sAdd('s', 5); -$redis->sAdd('s', 4); -$redis->sAdd('s', 2); -$redis->sAdd('s', 1); -$redis->sAdd('s', 3); - -var_dump($redis->sort('s')); // 1,2,3,4,5 -var_dump($redis->sort('s', ['sort' => 'desc'])); // 5,4,3,2,1 -var_dump($redis->sort('s', ['sort' => 'desc', 'store' => 'out'])); // (int)5 -``` - - - - -### ttl, pttl ------ -_**Description**_: Returns the time to live left for a given key in seconds (ttl), or milliseconds (pttl). - -##### *Parameters* -*Key*: key - -##### *Return value* -*LONG*: The time to live in seconds. If the key has no ttl, `-1` will be returned, and `-2` if the key doesn't exist. - -##### *Example* -```php -$redis->ttl('key'); -``` - -### persist ------ -_**Description**_: Remove the expiration timer from a key. - -##### *Parameters* -*Key*: key - -##### *Return value* -*BOOL*: `TRUE` if a timeout was removed, `FALSE` if the key didn’t exist or didn’t have an expiration timer. - -##### *Example* -```php -$redis->persist('key'); -``` - -### mSet, mSetNx ------ -_**Description**_: Sets multiple key-value pairs in one atomic command. MSETNX only returns TRUE if all the keys were set (see SETNX). - -##### *Parameters* -*Pairs*: [key => value, ...] - -##### *Return value* -*Bool* `TRUE` in case of success, `FALSE` in case of failure. - -##### *Example* -```php - -$redis->mSet(['key0' => 'value0', 'key1' => 'value1']); -var_dump($redis->get('key0')); -var_dump($redis->get('key1')); - -``` -Output: -``` -string(6) "value0" -string(6) "value1" -``` - - - -### dump ------ -_**Description**_: Dump a key out of a redis database, the value of which can later be passed into redis using the RESTORE command. The data -that comes out of DUMP is a binary representation of the key as Redis stores it. -##### *Parameters* -*key* string -##### *Return value* -The Redis encoded value of the key, or FALSE if the key doesn't exist -##### *Examples* -```php -$redis->set('foo', 'bar'); -$val = $redis->dump('foo'); // $val will be the Redis encoded key value -``` - -### restore ------ -_**Description**_: Restore a key from the result of a DUMP operation. -##### *Parameters* -*key* string. The key name -*ttl* integer. How long the key should live (if zero, no expire will be set on the key) -*value* string (binary). The Redis encoded key value (from DUMP) -##### *Examples* -```php -$redis->set('foo', 'bar'); -$val = $redis->dump('foo'); -$redis->restore('bar', 0, $val); // The key 'bar', will now be equal to the key 'foo' -``` - -### migrate ------ -_**Description**_: Migrates a key to a different Redis instance. - -**Note:**: Redis introduced migrating multiple keys in 3.0.6, so you must have at least -that version in order to call `migrate` with an array of keys. - -##### *Parameters* -*host* string. The destination host -*port* integer. The TCP port to connect to. -*key(s)* string or array. -*destination-db* integer. The target DB. -*timeout* integer. The maximum amount of time given to this transfer. -*copy* boolean, optional. Should we send the COPY flag to redis. -*replace* boolean, optional. Should we send the REPLACE flag to redis -##### *Examples* -```php -$redis->migrate('backup', 6379, 'foo', 0, 3600); -$redis->migrate('backup', 6379, 'foo', 0, 3600, true, true); /* copy and replace */ -$redis->migrate('backup', 6379, 'foo', 0, 3600, false, true); /* just REPLACE flag */ - -/* Migrate multiple keys (requires Redis >= 3.0.6) -$redis->migrate('backup', 6379, ['key1', 'key2', 'key3'], 0, 3600); -``` - - - -## Hashes - -* [hDel](#hdel) - Delete one or more hash fields -* [hExists](#hexists) - Determine if a hash field exists -* [hGet](#hget) - Get the value of a hash field -* [hGetAll](#hgetall) - Get all the fields and values in a hash -* [hIncrBy](#hincrby) - Increment the integer value of a hash field by the given number -* [hIncrByFloat](#hincrbyfloat) - Increment the float value of a hash field by the given amount -* [hKeys](#hkeys) - Get all the fields in a hash -* [hLen](#hlen) - Get the number of fields in a hash -* [hMGet](#hmget) - Get the values of all the given hash fields -* [hMSet](#hmset) - Set multiple hash fields to multiple values -* [hSet](#hset) - Set the string value of a hash field -* [hSetNx](#hsetnx) - Set the value of a hash field, only if the field does not exist -* [hVals](#hvals) - Get all the values in a hash -* [hScan](#hscan) - Scan a hash key for members -* [hStrLen](#hstrlen) - Get the string length of the value associated with field in the hash - -### hSet ------ -_**Description**_: Adds a value to the hash stored at key. -##### *Parameters* -*key* -*hashKey* -*value* - -##### *Return value* -*LONG* `1` if value didn't exist and was added successfully, `0` if the value was already present and was replaced, `FALSE` if there was an error. -##### *Example* -```php -$redis->del('h') -$redis->hSet('h', 'key1', 'hello'); /* 1, 'key1' => 'hello' in the hash at "h" */ -$redis->hGet('h', 'key1'); /* returns "hello" */ - -$redis->hSet('h', 'key1', 'plop'); /* 0, value was replaced. */ -$redis->hGet('h', 'key1'); /* returns "plop" */ -``` - -### hSetNx ------ -_**Description**_: Adds a value to the hash stored at key only if this field isn't already in the hash. - -##### *Return value* -*BOOL* `TRUE` if the field was set, `FALSE` if it was already present. - -##### *Example* -```php -$redis->del('h') -$redis->hSetNx('h', 'key1', 'hello'); /* TRUE, 'key1' => 'hello' in the hash at "h" */ -$redis->hSetNx('h', 'key1', 'world'); /* FALSE, 'key1' => 'hello' in the hash at "h". No change since the field wasn't replaced. */ -``` - - -### hGet ------ -_**Description**_: Gets a value from the hash stored at key. If the hash table doesn't exist, or the key doesn't exist, `FALSE` is returned. -##### *Parameters* -*key* -*hashKey* - -##### *Return value* -*STRING* The value, if the command executed successfully -*BOOL* `FALSE` in case of failure - - -### hLen ------ -_**Description**_: Returns the length of a hash, in number of items -##### *Parameters* -*key* - -##### *Return value* -*LONG* the number of items in a hash, `FALSE` if the key doesn't exist or isn't a hash. -##### *Example* -```php -$redis->del('h') -$redis->hSet('h', 'key1', 'hello'); -$redis->hSet('h', 'key2', 'plop'); -$redis->hLen('h'); /* returns 2 */ -``` - -### hDel ------ -_**Description**_: Removes a value from the hash stored at key. If the hash table doesn't exist, or the key doesn't exist, `FALSE` is returned. -##### *Parameters* -*key* -*hashKey1* -*hashKey2* -... - -##### *Return value* -*LONG* the number of deleted keys, 0 if the key doesn't exist, `FALSE` if the key isn't a hash. - - -### hKeys ------ -_**Description**_: Returns the keys in a hash, as an array of strings. - -##### *Parameters* -*Key*: key - -##### *Return value* -An array of elements, the keys of the hash. This works like PHP's array_keys(). - -##### *Example* -```php -$redis->del('h'); -$redis->hSet('h', 'a', 'x'); -$redis->hSet('h', 'b', 'y'); -$redis->hSet('h', 'c', 'z'); -$redis->hSet('h', 'd', 't'); -var_dump($redis->hKeys('h')); -``` - -Output: -``` -array(4) { - [0]=> - string(1) "a" - [1]=> - string(1) "b" - [2]=> - string(1) "c" - [3]=> - string(1) "d" -} -``` -The order is random and corresponds to redis' own internal representation of the set structure. - -### hVals ------ -_**Description**_: Returns the values in a hash, as an array of strings. - -##### *Parameters* -*Key*: key - -##### *Return value* -An array of elements, the values of the hash. This works like PHP's array_values(). - -##### *Example* -```php -$redis->del('h'); -$redis->hSet('h', 'a', 'x'); -$redis->hSet('h', 'b', 'y'); -$redis->hSet('h', 'c', 'z'); -$redis->hSet('h', 'd', 't'); -var_dump($redis->hVals('h')); -``` - -Output: -``` -array(4) { - [0]=> - string(1) "x" - [1]=> - string(1) "y" - [2]=> - string(1) "z" - [3]=> - string(1) "t" -} -``` -The order is random and corresponds to redis' own internal representation of the set structure. - -### hGetAll ------ -_**Description**_: Returns the whole hash, as an array of strings indexed by strings. - -##### *Parameters* -*Key*: key - -##### *Return value* -An array of elements, the contents of the hash. - -##### *Example* -```php -$redis->del('h'); -$redis->hSet('h', 'a', 'x'); -$redis->hSet('h', 'b', 'y'); -$redis->hSet('h', 'c', 'z'); -$redis->hSet('h', 'd', 't'); -var_dump($redis->hGetAll('h')); -``` - -Output: -``` -array(4) { - ["a"]=> - string(1) "x" - ["b"]=> - string(1) "y" - ["c"]=> - string(1) "z" - ["d"]=> - string(1) "t" -} -``` -The order is random and corresponds to redis' own internal representation of the set structure. - -### hExists ------ -_**Description**_: Verify if the specified member exists in a key. -##### *Parameters* -*key* -*memberKey* -##### *Return value* -*BOOL*: If the member exists in the hash table, return `TRUE`, otherwise return `FALSE`. -##### *Examples* -```php -$redis->hSet('h', 'a', 'x'); -$redis->hExists('h', 'a'); /* TRUE */ -$redis->hExists('h', 'NonExistingKey'); /* FALSE */ -``` - -### hIncrBy ------ -_**Description**_: Increments the value of a member from a hash by a given amount. -##### *Parameters* -*key* -*member* -*value*: (integer) value that will be added to the member's value -##### *Return value* -*LONG* the new value -##### *Examples* -```php -$redis->del('h'); -$redis->hIncrBy('h', 'x', 2); /* returns 2: h[x] = 2 now. */ -$redis->hIncrBy('h', 'x', 1); /* h[x] ← 2 + 1. Returns 3 */ -``` - -### hIncrByFloat ------ -_**Description**_: Increments the value of a hash member by the provided float value -##### *Parameters* -*key* -*member* -*value*: (float) value that will be added to the member's value -##### *Return value* -*FLOAT* the new value -##### *Examples* -```php -$redis->del('h'); -$redis->hIncrByFloat('h','x', 1.5); /* returns 1.5: h[x] = 1.5 now */ -$redis->hIncrByFloat('h', 'x', 1.5); /* returns 3.0: h[x] = 3.0 now */ -$redis->hIncrByFloat('h', 'x', -3.0); /* returns 0.0: h[x] = 0.0 now */ -``` - -### hMSet ------ -_**Description**_: Fills in a whole hash. Non-string values are converted to string, using the standard `(string)` cast. NULL values are stored as empty strings. -##### *Parameters* -*key* -*members*: key → value array -##### *Return value* -*BOOL* -##### *Examples* -```php -$redis->del('user:1'); -$redis->hMSet('user:1', ['name' => 'Joe', 'salary' => 2000]); -$redis->hIncrBy('user:1', 'salary', 100); // Joe earns 100 more now. -``` - -### hMGet ------ -_**Description**_: Retrieve the values associated to the specified fields in the hash. -##### *Parameters* -*key* -*memberKeys* Array -##### *Return value* -*Array* An array of elements, the values of the specified fields in the hash, with the hash keys as array keys. -##### *Examples* -```php -$redis->del('h'); -$redis->hSet('h', 'field1', 'value1'); -$redis->hSet('h', 'field2', 'value2'); -$redis->hMGet('h', ['field1', 'field2']); /* returns ['field1' => 'value1', 'field2' => 'value2'] */ -``` - -### hScan ------ -_**Description**_: Scan a HASH value for members, with an optional pattern and count -##### *Parameters* -*key*: String -*iterator*: Long (reference) -*pattern*: Optional pattern to match against -*count*: How many keys to return in a go (only a suggestion to Redis) -##### *Return value* -*Array* An array of members that match our pattern - -##### *Examples* -```php -$it = NULL; -/* Don't ever return an empty array until we're done iterating */ -$redis->setOption(Redis::OPT_SCAN, Redis::SCAN_RETRY); -while($arr_keys = $redis->hScan('hash', $it)) { - foreach($arr_keys as $str_field => $str_value) { - echo "$str_field => $str_value\n"; /* Print the hash member and value */ - } -} -``` - -### hStrLen ------ -_**Description**_: Get the string length of the value associated with field in the hash stored at key. -##### *Parameters* -*key*: String -*field*: String -##### *Return value* -*LONG* the string length of the value associated with field, or zero when field is not present in the hash or key does not exist at all. - -## Lists - -* [blPop, brPop](#blpop-brpop) - Remove and get the first/last element in a list -* [bRPopLPush](#brpoplpush) - Pop a value from a list, push it to another list and return it -* [lIndex](#lindex) - Get an element from a list by its index -* [lInsert](#linsert) - Insert an element before or after another element in a list -* [lLen](#llen) - Get the length/size of a list -* [lPop](#lpop) - Remove and get the first element in a list -* [lPush](#lpush) - Prepend one or multiple values to a list -* [lPushx](#lpushx) - Prepend a value to a list, only if the list exists -* [lRange](#lrange) - Get a range of elements from a list -* [lRem](#lrem) - Remove elements from a list -* [lSet](#lset) - Set the value of an element in a list by its index -* [lTrim](#ltrim) - Trim a list to the specified range -* [rPop](#rpop) - Remove and get the last element in a list -* [rPopLPush](#rpoplpush) - Remove the last element in a list, append it to another list and return it (redis >= 1.1) -* [rPush](#rpush) - Append one or multiple values to a list -* [rPushX](#rpushx) - Append a value to a list, only if the list exists - -### blPop, brPop ------ -_**Description**_: Is a blocking lPop(rPop) primitive. If at least one of the lists contains at least one element, the element will be popped from the head of the list and returned to the caller. -If all the list identified by the keys passed in arguments are empty, blPop will block during the specified timeout until an element is pushed to one of those lists. This element will be popped. - -##### *Parameters* -*ARRAY* Array containing the keys of the lists -*INTEGER* Timeout -Or -*STRING* Key1 -*STRING* Key2 -*STRING* Key3 -... -*STRING* Keyn -*INTEGER* Timeout - -##### *Return value* -*ARRAY* ['listName', 'element'] - -##### *Example* -```php -/* Non blocking feature */ -$redis->lPush('key1', 'A'); -$redis->del('key2'); - -$redis->blPop('key1', 'key2', 10); /* ['key1', 'A'] */ -/* OR */ -$redis->blPop(['key1', 'key2'], 10); /* ['key1', 'A'] */ - -$redis->brPop('key1', 'key2', 10); /* ['key1', 'A'] */ -/* OR */ -$redis->brPop(['key1', 'key2'], 10); /* ['key1', 'A'] */ - -/* Blocking feature */ - -/* process 1 */ -$redis->del('key1'); -$redis->blPop('key1', 10); -/* blocking for 10 seconds */ - -/* process 2 */ -$redis->lPush('key1', 'A'); - -/* process 1 */ -/* ['key1', 'A'] is returned*/ -``` - -### bRPopLPush ------ -_**Description**_: A blocking version of `rPopLPush`, with an integral timeout in the third parameter. - -##### *Parameters* -*Key*: srckey -*Key*: dstkey -*Long*: timeout - -##### *Return value* -*STRING* The element that was moved in case of success, `FALSE` in case of timeout. - -### lIndex ------ -_**Description**_: Return the specified element of the list stored at the specified key. - -0 the first element, 1 the second ... --1 the last element, -2 the penultimate ... - -Return `FALSE` in case of a bad index or a key that doesn't point to a list. - -##### *Parameters* -*key* -*index* - -##### *Return value* -*String* the element at this index -*Bool* `FALSE` if the key identifies a non-string data type, or no value corresponds to this index in the list `Key`. - -##### *Example* -```php -$redis->rPush('key1', 'A'); -$redis->rPush('key1', 'B'); -$redis->rPush('key1', 'C'); /* key1 => [ 'A', 'B', 'C' ] */ -$redis->lindex('key1', 0); /* 'A' */ -$redis->lindex('key1', -1); /* 'C' */ -$redis->lindex('key1', 10); /* `FALSE` */ -``` - -### lInsert ------ -_**Description**_: Insert value in the list before or after the pivot value. - -The parameter options specify the position of the insert (before or after). -If the list didn't exists, or the pivot didn't exists, the value is not inserted. - -##### *Parameters* -*key* -*position* Redis::BEFORE | Redis::AFTER -*pivot* -*value* - -##### *Return value* -The number of the elements in the list, -1 if the pivot didn't exists. - -##### *Example* -```php -$redis->del('key1'); -$redis->lInsert('key1', Redis::AFTER, 'A', 'X'); /* 0 */ - -$redis->lPush('key1', 'A'); -$redis->lPush('key1', 'B'); -$redis->lPush('key1', 'C'); - -$redis->lInsert('key1', Redis::BEFORE, 'C', 'X'); /* 4 */ -$redis->lRange('key1', 0, -1); /* ['A', 'B', 'X', 'C'] */ - -$redis->lInsert('key1', Redis::AFTER, 'C', 'Y'); /* 5 */ -$redis->lRange('key1', 0, -1); /* ['A', 'B', 'X', 'C', 'Y'] */ - -$redis->lInsert('key1', Redis::AFTER, 'W', 'value'); /* -1 */ -``` - -### lPop ------ -_**Description**_: Return and remove the first element of the list. - -##### *Parameters* -*key* - -##### *Return value* -*STRING* if command executed successfully -*BOOL* `FALSE` in case of failure (empty list) - -##### *Example* -```php -$redis->rPush('key1', 'A'); -$redis->rPush('key1', 'B'); -$redis->rPush('key1', 'C'); /* key1 => [ 'A', 'B', 'C' ] */ -$redis->lPop('key1'); /* key1 => [ 'B', 'C' ] */ -``` - -### lPush ------ -_**Description**_: Adds one or more values to the head of a LIST. Creates the list if the key didn't exist. If the key exists and is not a list, `FALSE` is returned. - -##### *Prototype* -```php -$redis->lPush($key, $entry [, $entry, $entry]); -``` - -##### *Return value* -*LONG* The new length of the list in case of success, `FALSE` in case of Failure. - -##### *Examples* -```php -$redis->del('key1'); -$redis->lPush('key1', 'F'); // returns 1 -$redis->lPush('key1', 'E'); // returns 2 -$redis->lPush('key1', 'D'); // returns 3 -/* key1 now contains: [ 'D', 'E', 'F' ] */ - -$redis->lPush('key1', 'C', 'B', 'A'); // Returns 6 -/* key1 now contains: [ 'A', 'B', 'C', 'D', 'E', 'F' ] -``` - -### lPushx ------ -_**Description**_: Adds the string value to the head (left) of the list if the list exists. - -##### *Parameters* -*key* -*value* String, value to push in key - -##### *Return value* -*LONG* The new length of the list in case of success, `FALSE` in case of Failure. - -##### *Examples* -```php -$redis->del('key1'); -$redis->lPushx('key1', 'A'); // returns 0 -$redis->lPush('key1', 'A'); // returns 1 -$redis->lPushx('key1', 'B'); // returns 2 -$redis->lPushx('key1', 'C'); // returns 3 -/* key1 now points to the following list: [ 'A', 'B', 'C' ] */ -``` - -### lRange ------ -_**Description**_: Returns the specified elements of the list stored at the specified key in the range [start, end]. start and stop are interpreted as indices: -0 the first element, 1 the second ... --1 the last element, -2 the penultimate ... - -##### *Parameters* -*key* -*start* -*end* - -##### *Return value* -*Array* containing the values in specified range. - -##### *Example* -```php -$redis->rPush('key1', 'A'); -$redis->rPush('key1', 'B'); -$redis->rPush('key1', 'C'); -$redis->lRange('key1', 0, -1); /* ['A', 'B', 'C'] */ -``` - -### lRem ------ -_**Description**_: Removes the first `count` occurrences of the value element from the list. If count is zero, all the matching elements are removed. If count is negative, elements are removed from tail to head. - -**Note**: The argument order is not the same as in the Redis documentation. This difference is kept for compatibility reasons. - -##### *Parameters* -*key* -*value* -*count* - -##### *Return value* -*LONG* the number of elements to remove -*BOOL* `FALSE` if the value identified by key is not a list. - -##### *Example* -```php -$redis->lPush('key1', 'A'); -$redis->lPush('key1', 'B'); -$redis->lPush('key1', 'C'); -$redis->lPush('key1', 'A'); -$redis->lPush('key1', 'A'); - -$redis->lRange('key1', 0, -1); /* ['A', 'A', 'C', 'B', 'A'] */ -$redis->lRem('key1', 'A', 2); /* 2 */ -$redis->lRange('key1', 0, -1); /* ['C', 'B', 'A'] */ -``` - -### lSet ------ -_**Description**_: Set the list at index with the new value. - -##### *Parameters* -*key* -*index* -*value* - -##### *Return value* -*BOOL* `TRUE` if the new value was set. `FALSE` if the index is out of range, or data type identified by key is not a list. - -##### *Example* -```php -$redis->rPush('key1', 'A'); -$redis->rPush('key1', 'B'); -$redis->rPush('key1', 'C'); /* key1 => [ 'A', 'B', 'C' ] */ -$redis->lindex('key1', 0); /* 'A' */ -$redis->lSet('key1', 0, 'X'); -$redis->lindex('key1', 0); /* 'X' */ -``` - -### lTrim ------ -_**Description**_: Trims an existing list so that it will contain only a specified range of elements. - -##### *Parameters* -*key* -*start* -*stop* - -##### *Return value* -*Array* -*Bool* return `FALSE` if the key identify a non-list value. - -##### *Example* -```php -$redis->rPush('key1', 'A'); -$redis->rPush('key1', 'B'); -$redis->rPush('key1', 'C'); -$redis->lRange('key1', 0, -1); /* ['A', 'B', 'C'] */ -$redis->lTrim('key1', 0, 1); -$redis->lRange('key1', 0, -1); /* ['A', 'B'] */ -``` - -### rPop ------ -_**Description**_: Returns and removes the last element of the list. - -##### *Parameters* -*key* - -##### *Return value* -*STRING* if command executed successfully -*BOOL* `FALSE` in case of failure (empty list) - -##### *Example* -```php -$redis->rPush('key1', 'A'); -$redis->rPush('key1', 'B'); -$redis->rPush('key1', 'C'); /* key1 => [ 'A', 'B', 'C' ] */ -$redis->rPop('key1'); /* key1 => [ 'A', 'B' ] */ -``` - -### rPopLPush ------ -_**Description**_: Pops a value from the tail of a list, and pushes it to the front of another list. Also return this value. (redis >= 1.1) - -##### *Parameters* -*Key*: srckey -*Key*: dstkey - -##### *Return value* -*STRING* The element that was moved in case of success, `FALSE` in case of failure. - -##### *Example* -```php -$redis->del('x', 'y'); - -$redis->lPush('x', 'abc'); -$redis->lPush('x', 'def'); -$redis->lPush('y', '123'); -$redis->lPush('y', '456'); - -// move the last of x to the front of y. -var_dump($redis->rPopLPush('x', 'y')); -var_dump($redis->lRange('x', 0, -1)); -var_dump($redis->lRange('y', 0, -1)); - -``` -Output: -``` -string(3) "abc" -array(1) { - [0]=> - string(3) "def" -} -array(3) { - [0]=> - string(3) "abc" - [1]=> - string(3) "456" - [2]=> - string(3) "123" -} -``` - -### rPush ------ -_**Description**_: Adds one or more entries to the tail of a LIST. Redis will create the list if it doesn't exist. - -##### *Prototype* -```php -$redis->rPush($key, $entry [, $entry, $entry]); -``` - -##### *Return value* -*LONG* The new length of the list in case of success, `FALSE` in case of Failure. - -##### *Examples* -```php -$redis->del('key1'); -$redis->rPush('key1', 'A'); // returns 1 -$redis->rPush('key1', 'B'); // returns 2 -$redis->rPush('key1', 'C'); // returns 3 -$redis->rPush('key1', 'D', 'E', 'F'); // returns 6 -/* key1 now contains: [ 'A', 'B', 'C', 'D', 'E', 'F' ] */ -``` - -### rPushX ------ -_**Description**_: Adds the string value to the tail (right) of the list if the list exists. `FALSE` in case of Failure. - -##### *Parameters* -*key* -*value* String, value to push in key - -##### *Return value* -*LONG* The new length of the list in case of success, `FALSE` in case of Failure. - -##### *Examples* -```php -$redis->del('key1'); -$redis->rPushX('key1', 'A'); // returns 0 -$redis->rPush('key1', 'A'); // returns 1 -$redis->rPushX('key1', 'B'); // returns 2 -$redis->rPushX('key1', 'C'); // returns 3 -/* key1 now points to the following list: [ 'A', 'B', 'C' ] */ -``` - -### lLen ------ -_**Description**_: Returns the size of a list identified by Key. - -If the list didn't exist or is empty, the command returns 0. If the data type identified by Key is not a list, the command return `FALSE`. - -##### *Parameters* -*Key* - -##### *Return value* -*LONG* The size of the list identified by Key exists. -*BOOL* `FALSE` if the data type identified by Key is not list - -##### *Example* -```php -$redis->rPush('key1', 'A'); -$redis->rPush('key1', 'B'); -$redis->rPush('key1', 'C'); /* key1 => [ 'A', 'B', 'C' ] */ -$redis->lLen('key1');/* 3 */ -$redis->rPop('key1'); -$redis->lLen('key1');/* 2 */ -``` - - -## Sets - -* [sAdd](#sadd) - Add one or more members to a set -* [sCard](#scard) - Get the number of members in a set -* [sDiff](#sdiff) - Subtract multiple sets -* [sDiffStore](#sdiffstore) - Subtract multiple sets and store the resulting set in a key -* [sInter](#sinter) - Intersect multiple sets -* [sInterStore](#sinterstore) - Intersect multiple sets and store the resulting set in a key -* [sIsMember](#sismember) - Determine if a given value is a member of a set -* [sMembers](#smembers) - Get all the members in a set -* [sMove](#smove) - Move a member from one set to another -* [sPop](#spop) - Remove and return one or more members of a set at random -* [sRandMember](#srandmember) - Get one or multiple random members from a set -* [sRem](#srem) - Remove one or more members from a set -* [sUnion](#sunion) - Add multiple sets -* [sUnionStore](#sunionstore) - Add multiple sets and store the resulting set in a key -* [sScan](#sscan) - Scan a set for members - -### sAdd ------ -_**Description**_: Adds a value to the set value stored at key. -##### *Parameters* -*key* -*value* - -##### *Return value* -*LONG* the number of elements added to the set. -##### *Example* -```php -$redis->sAdd('key1' , 'member1'); /* 1, 'key1' => {'member1'} */ -$redis->sAdd('key1' , 'member2', 'member3'); /* 2, 'key1' => {'member1', 'member2', 'member3'}*/ -$redis->sAdd('key1' , 'member2'); /* 0, 'key1' => {'member1', 'member2', 'member3'}*/ -``` - -### sCard ------ -_**Description**_: Returns the cardinality of the set identified by key. -##### *Parameters* -*key* -##### *Return value* -*LONG* the cardinality of the set identified by key, 0 if the set doesn't exist. -##### *Example* -```php -$redis->sAdd('key1' , 'member1'); -$redis->sAdd('key1' , 'member2'); -$redis->sAdd('key1' , 'member3'); /* 'key1' => {'member1', 'member2', 'member3'}*/ -$redis->sCard('key1'); /* 3 */ -$redis->sCard('keyX'); /* 0 */ -``` - -### sDiff ------ -_**Description**_: Performs the difference between N sets and returns it. - -##### *Parameters* -*Keys*: key1, key2, ... , keyN: Any number of keys corresponding to sets in redis. - -##### *Return value* -*Array of strings*: The difference of the first set will all the others. - -##### *Example* -```php -$redis->del('s0', 's1', 's2'); - -$redis->sAdd('s0', '1'); -$redis->sAdd('s0', '2'); -$redis->sAdd('s0', '3'); -$redis->sAdd('s0', '4'); - -$redis->sAdd('s1', '1'); -$redis->sAdd('s2', '3'); - -var_dump($redis->sDiff('s0', 's1', 's2')); -``` -Return value: all elements of s0 that are neither in s1 nor in s2. -``` -array(2) { - [0]=> - string(1) "4" - [1]=> - string(1) "2" -} -``` - -### sDiffStore ------ -_**Description**_: Performs the same action as sDiff, but stores the result in the first key -##### *Parameters* -*Key*: dstkey, the key to store the diff into. - -*Keys*: key1, key2, ... , keyN: Any number of keys corresponding to sets in redis -##### *Return value* -*INTEGER*: The cardinality of the resulting set, or `FALSE` in case of a missing key. - -##### *Example* -```php -$redis->del('s0', 's1', 's2'); - -$redis->sAdd('s0', '1'); -$redis->sAdd('s0', '2'); -$redis->sAdd('s0', '3'); -$redis->sAdd('s0', '4'); - -$redis->sAdd('s1', '1'); -$redis->sAdd('s2', '3'); - -var_dump($redis->sDiffStore('dst', 's0', 's1', 's2')); -var_dump($redis->sMembers('dst')); -``` -Return value: the number of elements of s0 that are neither in s1 nor in s2. -``` -int(2) -array(2) { - [0]=> - string(1) "4" - [1]=> - string(1) "2" -} -``` - -### sInter ------ -_**Description**_: Returns the members of a set resulting from the intersection of all the sets held at the specified keys. - -If just a single key is specified, then this command produces the members of this set. If one of the keys -is missing, `FALSE` is returned. - -##### *Parameters* - -key1, key2, keyN: keys identifying the different sets on which we will apply the intersection. - -##### *Return value* - -Array, contain the result of the intersection between those keys. If the intersection between the different sets is empty, the return value will be empty array. - -##### *Examples* -```php -$redis->sAdd('key1', 'val1'); -$redis->sAdd('key1', 'val2'); -$redis->sAdd('key1', 'val3'); -$redis->sAdd('key1', 'val4'); - -$redis->sAdd('key2', 'val3'); -$redis->sAdd('key2', 'val4'); - -$redis->sAdd('key3', 'val3'); -$redis->sAdd('key3', 'val4'); - -var_dump($redis->sInter('key1', 'key2', 'key3')); -``` - -Output: - -``` -array(2) { - [0]=> - string(4) "val4" - [1]=> - string(4) "val3" -} -``` - -### sInterStore ------ -_**Description**_: Performs a sInter command and stores the result in a new set. -##### *Parameters* -*Key*: dstkey, the key to store the diff into. - -*Keys*: key1, key2... keyN. key1..keyN are intersected as in sInter. - -##### *Return value* -*INTEGER*: The cardinality of the resulting set, or `FALSE` in case of a missing key. - -##### *Example* -```php -$redis->sAdd('key1', 'val1'); -$redis->sAdd('key1', 'val2'); -$redis->sAdd('key1', 'val3'); -$redis->sAdd('key1', 'val4'); - -$redis->sAdd('key2', 'val3'); -$redis->sAdd('key2', 'val4'); - -$redis->sAdd('key3', 'val3'); -$redis->sAdd('key3', 'val4'); - -var_dump($redis->sInterStore('output', 'key1', 'key2', 'key3')); -var_dump($redis->sMembers('output')); -``` - -Output: - -``` -int(2) - -array(2) { - [0]=> - string(4) "val4" - [1]=> - string(4) "val3" -} -``` - -### sIsMember ------ -_**Description**_: Checks if `value` is a member of the set stored at the key `key`. -##### *Parameters* -*key* -*value* - -##### *Return value* -*BOOL* `TRUE` if `value` is a member of the set at key `key`, `FALSE` otherwise. -##### *Example* -```php -$redis->sAdd('key1' , 'member1'); -$redis->sAdd('key1' , 'member2'); -$redis->sAdd('key1' , 'member3'); /* 'key1' => {'member1', 'member2', 'member3'}*/ - -$redis->sIsMember('key1', 'member1'); /* TRUE */ -$redis->sIsMember('key1', 'memberX'); /* FALSE */ -``` - -### sMembers ------ -_**Description**_: Returns the contents of a set. - -##### *Parameters* -*Key*: key - -##### *Return value* -An array of elements, the contents of the set. - -##### *Example* -```php -$redis->del('s'); -$redis->sAdd('s', 'a'); -$redis->sAdd('s', 'b'); -$redis->sAdd('s', 'a'); -$redis->sAdd('s', 'c'); -var_dump($redis->sMembers('s')); -``` - -Output: -``` -array(3) { - [0]=> - string(1) "c" - [1]=> - string(1) "a" - [2]=> - string(1) "b" -} -``` -The order is random and corresponds to redis' own internal representation of the set structure. - -### sMove ------ -_**Description**_: Moves the specified member from the set at srcKey to the set at dstKey. -##### *Parameters* -*srcKey* -*dstKey* -*member* -##### *Return value* -*BOOL* If the operation is successful, return `TRUE`. If the srcKey and/or dstKey didn't exist, and/or the member didn't exist in srcKey, `FALSE` is returned. -##### *Example* -```php -$redis->sAdd('key1' , 'member11'); -$redis->sAdd('key1' , 'member12'); -$redis->sAdd('key1' , 'member13'); /* 'key1' => {'member11', 'member12', 'member13'}*/ -$redis->sAdd('key2' , 'member21'); -$redis->sAdd('key2' , 'member22'); /* 'key2' => {'member21', 'member22'}*/ -$redis->sMove('key1', 'key2', 'member13'); /* 'key1' => {'member11', 'member12'} */ - /* 'key2' => {'member21', 'member22', 'member13'} */ - -``` - -### sPop ------ -_**Description**_: Removes and returns a random element from the set value at Key. -##### *Parameters* -*key* -*count*: Integer, optional -##### *Return value (without count argument)* -*String* "popped" value -*Bool* `FALSE` if set identified by key is empty or doesn't exist. -##### *Return value (with count argument)* -*Array*: Member(s) returned or an empty array if the set doesn't exist -*Bool*: `FALSE` on error if the key is not a set -##### *Example* -```php -$redis->sAdd('key1' , 'member1'); -$redis->sAdd('key1' , 'member2'); -$redis->sAdd('key1' , 'member3'); /* 'key1' => {'member3', 'member1', 'member2'}*/ -$redis->sPop('key1'); /* 'member1', 'key1' => {'member3', 'member2'} */ -$redis->sPop('key1'); /* 'member3', 'key1' => {'member2'} */ - -/* With count */ -$redis->sAdd('key2', 'member1', 'member2', 'member3'); -$redis->sPop('key2', 3); /* Will return all members but in no particular order */ -``` - -### sRandMember ------ -_**Description**_: Returns a random element from the set value at Key, without removing it. -##### *Parameters* -*key* -*count* (Integer, optional) -##### *Return value* -If no count is provided, a random *String* value from the set will be returned. If a count -is provided, an array of values from the set will be returned. Read about the different -ways to use the count here: [SRANDMEMBER](http://redis.io/commands/srandmember) -*Bool* `FALSE` if set identified by key is empty or doesn't exist. -##### *Example* -```php -$redis->sAdd('key1' , 'member1'); -$redis->sAdd('key1' , 'member2'); -$redis->sAdd('key1' , 'member3'); /* 'key1' => {'member3', 'member1', 'member2'}*/ - -// No count -$redis->sRandMember('key1'); /* 'member1', 'key1' => {'member3', 'member1', 'member2'} */ -$redis->sRandMember('key1'); /* 'member3', 'key1' => {'member3', 'member1', 'member2'} */ - -// With a count -$redis->sRandMember('key1', 3); // Will return an array with all members from the set -$redis->sRandMember('key1', 2); // Will an array with 2 members of the set -$redis->sRandMember('key1', -100); // Will return an array of 100 elements, picked from our set (with dups) -$redis->sRandMember('empty-set', 100); // Will return an empty array -$redis->sRandMember('not-a-set', 100); // Will return FALSE -``` - -### sRem ------ -_**Description**_: Removes the specified member from the set value stored at key. -##### *Parameters* -*key* -*member* -##### *Return value* -*LONG* The number of elements removed from the set. -##### *Example* -```php -$redis->sAdd('key1' , 'member1'); -$redis->sAdd('key1' , 'member2'); -$redis->sAdd('key1' , 'member3'); /* 'key1' => {'member1', 'member2', 'member3'}*/ -$redis->sRem('key1', 'member2', 'member3'); /*return 2. 'key1' => {'member1'} */ -``` - -### sUnion ------ -_**Description**_: Performs the union between N sets and returns it. - -##### *Parameters* -*Keys*: key1, key2, ... , keyN: Any number of keys corresponding to sets in redis. - -##### *Return value* -*Array of strings*: The union of all these sets. - -**Note:** `sUnion` can also take a single array with keys (see example below). - -##### *Example* -```php -$redis->del('s0', 's1', 's2'); - -$redis->sAdd('s0', '1'); -$redis->sAdd('s0', '2'); -$redis->sAdd('s1', '3'); -$redis->sAdd('s1', '1'); -$redis->sAdd('s2', '3'); -$redis->sAdd('s2', '4'); - -/* Get the union with variadic arguments */ -var_dump($redis->sUnion('s0', 's1', 's2')); - -/* Pass a single array */ -var_dump($redis->sUnion(['s0', 's1', 's2'])); - -``` -Return value: all elements that are either in s0 or in s1 or in s2. -``` -array(4) { - [0]=> - string(1) "3" - [1]=> - string(1) "4" - [2]=> - string(1) "1" - [3]=> - string(1) "2" -} -``` - -### sUnionStore ------ -_**Description**_: Performs the same action as sUnion, but stores the result in the first key - -##### *Parameters* -*Key*: dstkey, the key to store the diff into. - -*Keys*: key1, key2, ... , keyN: Any number of keys corresponding to sets in redis. - -##### *Return value* -*INTEGER*: The cardinality of the resulting set, or `FALSE` in case of a missing key. - -##### *Example* -```php -$redis->del('s0', 's1', 's2'); - -$redis->sAdd('s0', '1'); -$redis->sAdd('s0', '2'); -$redis->sAdd('s1', '3'); -$redis->sAdd('s1', '1'); -$redis->sAdd('s2', '3'); -$redis->sAdd('s2', '4'); - -var_dump($redis->sUnionStore('dst', 's0', 's1', 's2')); -var_dump($redis->sMembers('dst')); -``` -Return value: the number of elements that are either in s0 or in s1 or in s2. -``` -int(4) -array(4) { - [0]=> - string(1) "3" - [1]=> - string(1) "4" - [2]=> - string(1) "1" - [3]=> - string(1) "2" -} -``` - -### sScan ------ -_**Description**_: Scan a set for members - -##### *Parameters* -*Key*: The set to search -*iterator*: LONG (reference) to the iterator as we go -*pattern*: String, optional pattern to match against -*count*: How many members to return at a time (Redis might return a different amount) - -##### *Return value* -*Array, boolean*: PHPRedis will return an array of keys or FALSE when we're done iterating - -##### *Example* -```php -$it = NULL; -$redis->setOption(Redis::OPT_SCAN, Redis::SCAN_RETRY); /* don't return empty results until we're done */ -while($arr_mems = $redis->sScan('set', $it, "*pattern*")) { - foreach($arr_mems as $str_mem) { - echo "Member: $str_mem\n"; - } -} - -$it = NULL; -$redis->setOption(Redis::OPT_SCAN, Redis::SCAN_NORETRY); /* return after each iteration, even if empty */ -while(($arr_mems = $redis->sScan('set', $it, "*pattern*"))!==FALSE) { - if(count($arr_mems) > 0) { - foreach($arr_mems as $str_mem) { - echo "Member found: $str_mem\n"; - } - } else { - echo "No members in this iteration, iterator value: $it\n"; - } -} -``` - -## Sorted sets - -* [bzPop](#bzpop) - Block until Redis can pop the highest or lowest scoring member from one or more ZSETs. -* [zAdd](#zadd) - Add one or more members to a sorted set or update its score if it already exists -* [zCard](#zcard) - Get the number of members in a sorted set -* [zCount](#zcount) - Count the members in a sorted set with scores within the given values -* [zDiff](#zdiff) - Computes the difference between the first and all successive input sorted sets and return the resulting sorted set -* [zdiffstore](#zdiffstore) - Computes the difference between the first and all successive input sorted sets and stores the result in a new key -* [zIncrBy](#zincrby) - Increment the score of a member in a sorted set -* [zInter](#zinter) - Intersect multiple sorted sets and return the resulting sorted set -* [zinterstore](#zinterstore) - Intersect multiple sorted sets and store the resulting sorted set in a new key -* [zMscore](#zmscore) - Get the scores associated with the given members in a sorted set -* [zPop](#zpop) - Redis can pop the highest or lowest scoring member from one a ZSET. -* [zRange](#zrange) - Return a range of members in a sorted set, by index -* [zRangeByScore, zRevRangeByScore](#zrangebyscore-zrevrangebyscore) - Return a range of members in a sorted set, by score -* [zRangeByLex](#zrangebylex) - Return a lexicographical range from members that share the same score -* [zRank, zRevRank](#zrank-zrevrank) - Determine the index of a member in a sorted set -* [zRem](#zrem) - Remove one or more members from a sorted set -* [zRemRangeByRank](#zremrangebyrank) - Remove all members in a sorted set within the given indexes -* [zRemRangeByScore](#zremrangebyscore) - Remove all members in a sorted set within the given scores -* [zRevRange](#zrevrange) - Return a range of members in a sorted set, by index, with scores ordered from high to low -* [zScore](#zscore) - Get the score associated with the given member in a sorted set -* [zUnion](#zunion) - Add multiple sorted sets and return the resulting sorted set -* [zunionstore](#zunionstore) - Add multiple sorted sets and store the resulting sorted set in a new key -* [zScan](#zscan) - Scan a sorted set for members - -### bzPop ------ -_**Description**_: Block until Redis can pop the highest or lowest scoring members from one or more ZSETs. There are two commands (`BZPOPMIN` and `BZPOPMAX` for popping the lowest and highest scoring elements respectively.) - -##### *Prototype* -```php -$redis->bzPopMin(array $keys, int $timeout): array -$redis->bzPopMax(array $keys, int $timeout): array - -$redis->bzPopMin(string $key1, string $key2, ... int $timeout): array -$redis->bzPopMax(string $key1, string $key2, ... int $timeout): array -``` - -##### *Return value* -*ARRAY:* Either an array with the key member and score of the highest or lowest element or an empty array if the timeout was reached without an element to pop. - -##### *Example* -```php -/* Wait up to 5 seconds to pop the *lowest* scoring member from sets `zs1` and `zs2`. */ -$redis->bzPopMin(['zs1', 'zs2'], 5); -$redis->bzPopMin('zs1', 'zs2', 5); - -/* Wait up to 5 seconds to pop the *highest* scoring member from sets `zs1` and `zs2` */ -$redis->bzPopMax(['zs1', 'zs2'], 5); -$redis->bzPopMax('zs1', 'zs2', 5); -``` - -**Note:** Calling these functions with an array of keys or with a variable number of arguments is functionally identical. - -### zAdd ------ -_**Description**_: Add one or more members to a sorted set or update its score if it already exists - - -##### *Prototype* -```php -$redis->zAdd($key, [ $options ,] $score, $value [, $score1, $value1, ...]); -``` - -##### *Parameters* -*key*: string -*options*: array (optional) -*score*: double -*value*: string -*score1*: double -*value1*: string - -##### *Return value* -*Long* 1 if the element is added. 0 otherwise. - -##### *Example* -```php -$redis->zAdd('key', 1, 'val1'); -$redis->zAdd('key', 0, 'val0'); -$redis->zAdd('key', 5, 'val5'); -$redis->zRange('key', 0, -1); // [val0, val1, val5] - -// From Redis 3.0.2 it's possible to add options like XX, NX, CH, INCR -$redis->zAdd('key', ['CH'], 5, 'val5', 10, 'val10', 15, 'val15'); -``` - -### zCard ------ -_**Description**_: Returns the cardinality of an ordered set. - -##### *Parameters* -*key* - -##### *Return value* -*Long*, the set's cardinality - -##### *Example* -```php -$redis->zAdd('key', 0, 'val0'); -$redis->zAdd('key', 2, 'val2'); -$redis->zAdd('key', 10, 'val10'); -$redis->zCard('key'); /* 3 */ -``` - -### zCount ------ -_**Description**_: Returns the *number* of elements of the sorted set stored at the specified key which have scores in the range [start,end]. Adding a parenthesis before `start` or `end` excludes it from the range. +inf and -inf are also valid limits. - -##### *Parameters* -*key* -*start*: string -*end*: string - -##### *Return value* -*LONG* the size of a corresponding zRangeByScore. - -##### *Example* -```php -$redis->zAdd('key', 0, 'val0'); -$redis->zAdd('key', 2, 'val2'); -$redis->zAdd('key', 10, 'val10'); -$redis->zCount('key', 0, 3); /* 2, corresponding to ['val0', 'val2'] */ -``` - -### zDiff ------ -_**Description**_: Computes the difference between the first and all successive input sorted sets in the first argument. The result of the difference will be returned. - -The second argument is a set of options. It can define `WITHSCORES` so that the scores are returned as well. - -##### *Parameters* -*arrayZSetKeys* -*arrayOptions* One option is available: `withscores => TRUE`. - -##### *Return value* -*ARRAY* The result of the difference of sets. - -##### *Example* -```php -$redis->del('k1'); -$redis->del('k2'); -$redis->del('k3'); - -$redis->zAdd('k1', 0, 'val0'); -$redis->zAdd('k1', 1, 'val1'); -$redis->zAdd('k1', 3, 'val3'); - -$redis->zAdd('k2', 5, 'val1'); - -$redis->zAdd('k3', 5, 'val0'); -$redis->zAdd('k3', 3, 'val4'); - -$redis->zDiff(['k1', 'k2']); /* ['val0', 'val3'] */ -$redis->zDiff(['k2', 'k1']); /* [] */ -$redis->zDiff(['k1', 'k2'], ['withscores' => true]); /* ['val0' => 0.0, 'val3' => 3.0] */ - -$redis->zDiff(['k1', 'k2', 'k3']); /* ['val3'] */ -$redis->zDiff(['k3', 'k2', 'k1']); /* ['val4'] */ -``` - -### zdiffstore ------ -_**Description**_: Computes the difference between the first and all successive input sorted sets in the second argument. The result of the difference will be stored in the sorted set defined by the first argument. - -##### *Parameters* -*keyOutput* -*arrayZSetKeys* - -##### *Return value* -*LONG* The number of values in the new sorted set. - -##### *Example* -```php -$redis->del('k1'); -$redis->del('k2'); -$redis->del('k3'); - -$redis->zAdd('k1', 0, 'val0'); -$redis->zAdd('k1', 1, 'val1'); -$redis->zAdd('k1', 3, 'val3'); - -$redis->zAdd('k2', 5, 'val1'); - -$redis->zAdd('k3', 5, 'val0'); -$redis->zAdd('k3', 3, 'val4'); - -$redis->zdiffstore('ko1', ['k1', 'k2']); /* 2, 'ko1' => ['val0', 'val3'] */ -$redis->zdiffstore('ko2', ['k2', 'k1']); /* 0, 'ko2' => [] */ - -$redis->zdiffstore('ko3', ['k1', 'k2', 'k3']); /* 1, 'ko3' => ['val3'] */ -$redis->zdiffstore('ko4', ['k3', 'k2', 'k1']); /* 1, 'k04' => ['val4'] */ -``` - -### zIncrBy ------ -_**Description**_: Increments the score of a member from a sorted set by a given amount. - -##### *Parameters* -*key* -*value*: (double) value that will be added to the member's score -*member* - -##### *Return value* -*DOUBLE* the new value - -##### *Examples* -```php -$redis->del('key'); -$redis->zIncrBy('key', 2.5, 'member1'); /* key or member1 didn't exist, so member1's score is to 0 before the increment */ - /* and now has the value 2.5 */ -$redis->zIncrBy('key', 1, 'member1'); /* 3.5 */ -``` - -### zInter ------ -_**Description**_: Creates an intersection of sorted sets given in first argument. The result of the intersection will be returned. - -The second optional argument defines `weights` to apply to the sorted sets in input. In this case, the `weights` will be multiplied by the score of each element in the sorted set before applying the aggregation. -The third argument is a set of options. It can define the `AGGREGATE` option which specify how the results of the intersection are aggregated. It can also define `WITHSCORES` so that the scores are returned as well. - -##### *Parameters* -*arrayZSetKeys* -*arrayWeights* -*arrayOptions* Two options are available: `withscores => TRUE`, and `aggregate => $behaviour`. Either "SUM", "MIN", or "MAX" defines the behaviour to use on duplicate entries during the zinter. - -##### *Return value* -*ARRAY* The result of the intersection of sets. - -##### *Example* -```php -$redis->del('k1'); -$redis->del('k2'); -$redis->del('k3'); - -$redis->zAdd('k1', 0, 'val0'); -$redis->zAdd('k1', 1, 'val1'); -$redis->zAdd('k1', 3, 'val3'); - -$redis->zAdd('k2', 5, 'val1'); -$redis->zAdd('k2', 3, 'val3'); - -$redis->zinter(['k1', 'k2']); /* ['val1', 'val3'] */ -$redis->zinter(['k1', 'k2'], [1, 1]); /* ['val1', 'val3'] */ - -/* Weighted zinter */ -$redis->zinter(['k1', 'k2'], [1, 5], 'min'); /* ['val1', 'val3'] */ -$redis->zinter(['k1', 'k2'], [1, 5], 'max'); /* ['val3', 'val1'] */ -``` - -### zinterstore ------ -_**Description**_: Creates an intersection of sorted sets given in second argument. The result of the intersection will be stored in the sorted set defined by the first argument. - -The third optional argument defines `weights` to apply to the sorted sets in input. In this case, the `weights` will be multiplied by the score of each element in the sorted set before applying the aggregation. -The forth argument defines the `AGGREGATE` option which specify how the results of the intersection are aggregated. - -##### *Parameters* -*keyOutput* -*arrayZSetKeys* -*arrayWeights* -*aggregateFunction* Either "SUM", "MIN", or "MAX": defines the behaviour to use on duplicate entries during the zinterstore. - -##### *Return value* -*LONG* The number of values in the new sorted set. - -##### *Example* -```php -$redis->del('k1'); -$redis->del('k2'); -$redis->del('k3'); - -$redis->del('ko1'); -$redis->del('ko2'); -$redis->del('ko3'); -$redis->del('ko4'); - -$redis->zAdd('k1', 0, 'val0'); -$redis->zAdd('k1', 1, 'val1'); -$redis->zAdd('k1', 3, 'val3'); - -$redis->zAdd('k2', 5, 'val1'); -$redis->zAdd('k2', 3, 'val3'); - -$redis->zinterstore('ko1', ['k1', 'k2']); /* 2, 'ko1' => ['val1', 'val3'] */ -$redis->zinterstore('ko2', ['k1', 'k2'], [1, 1]); /* 2, 'ko2' => ['val1', 'val3'] */ - -/* Weighted zinterstore */ -$redis->zinterstore('ko3', ['k1', 'k2'], [1, 5], 'min'); /* 2, 'ko3' => ['val1', 'val3'] */ -$redis->zinterstore('ko4', ['k1', 'k2'], [1, 5], 'max'); /* 2, 'ko4' => ['val3', 'val1'] */ -``` - -### zMscore ------ -_**Description**_: Returns the scores of the given members in the specified sorted set. - -##### *Parameters* -*key* -*members*: member1, member2, ... , memberN: Any number of members in the specified sorted set. - -##### *Return value* -*ARRAY* or *FALSE* when the key is not found. Array entries corresponding to members that do not exist will be `false`. - -##### *Example* -```php -$redis->zAdd('key', 2.5, 'val2'); -$redis->zAdd('key', 4.5, 'val4'); - -$redis->zMscore('key', 'val2', 'val3', 'val4'); /* [2.5, false, 4.5] */ -``` - -### zPop ------ -_**Description**_: Can pop the highest or lowest scoring members from one ZSETs. There are two commands (`ZPOPMIN` and `ZPOPMAX` for popping the lowest and highest scoring elements respectively.) - -##### *Prototype* -```php -$redis->zPopMin(string $key, int $count): array -$redis->zPopMax(string $key, int $count): array - -$redis->zPopMin(string $key, int $count): array -$redis->zPopMax(string $key, int $count): array -``` - -##### *Return value* -*ARRAY:* Either an array with the key member and score of the highest or lowest element or an empty array if there is no element available. - -##### *Example* -```php -/* Pop the *lowest* scoring member from set `zs1`. */ -$redis->zPopMin('zs1', 5); - -/* Pop the *highest* scoring member from set `zs1`. */ -$redis->zPopMax('zs1', 5); -``` - -### zRange ------ -_**Description**_: Returns a range of elements from the ordered set stored at the specified key, with values in the range [start, end]. - -Start and stop are interpreted as zero-based indices: -`0` the first element, `1` the second ... -`-1` the last element, `-2` the penultimate ... - -##### *Parameters* -*key* -*start*: long -*end*: long -*withscores*: bool = false - -##### *Return value* -*Array* containing the values in specified range. - -##### *Example* -```php -$redis->zAdd('key1', 0, 'val0'); -$redis->zAdd('key1', 2, 'val2'); -$redis->zAdd('key1', 10, 'val10'); -$redis->zRange('key1', 0, -1); /* ['val0', 'val2', 'val10'] */ - -// with scores -$redis->zRange('key1', 0, -1, true); /* ['val0' => 0, 'val2' => 2, 'val10' => 10] */ -``` - -### zRangeByScore, zRevRangeByScore ------ -_**Description**_: Returns the elements of the sorted set stored at the specified key which have scores in the range [start,end]. Adding a parenthesis before `start` or `end` excludes it from the range. +inf and -inf are also valid limits. zRevRangeByScore returns the same items in reverse order, when the `start` and `end` parameters are swapped. - -##### *Parameters* -*key* -*start*: string -*end*: string -*options*: array - -Two options are available: `withscores => TRUE`, and `limit => [$offset, $count]` - -##### *Return value* -*Array* containing the values in specified range. - -##### *Example* -```php -$redis->zAdd('key', 0, 'val0'); -$redis->zAdd('key', 2, 'val2'); -$redis->zAdd('key', 10, 'val10'); -$redis->zRangeByScore('key', 0, 3); /* ['val0', 'val2'] */ -$redis->zRangeByScore('key', 0, 3, ['withscores' => TRUE]); /* ['val0' => 0, 'val2' => 2] */ -$redis->zRangeByScore('key', 0, 3, ['limit' => [1, 1]]); /* ['val2'] */ -$redis->zRangeByScore('key', 0, 3, ['withscores' => TRUE, 'limit' => [1, 1]]); /* ['val2' => 2] */ -$redis->zRangeByScore('key', '-inf', '+inf', ['withscores' => TRUE]); /* ['val0' => 0, 'val2' => 2, 'val10' => 10] */ -``` - -### zRangeByLex ------ -_**Description**_: Returns a lexicographical range of members in a sorted set, assuming the members have the same score. The min and max values are required to start with '(' (exclusive), '[' (inclusive), or be exactly the values '-' (negative inf) or '+' (positive inf). The command must be called with either three *or* five arguments or will return FALSE. - -##### *Parameters* -*key*: The ZSET you wish to run against -*min*: The minimum alphanumeric value you wish to get -*max*: The maximum alphanumeric value you wish to get -*offset*: Optional argument if you wish to start somewhere other than the first element. -*limit*: Optional argument if you wish to limit the number of elements returned. - -##### *Return value* -*Array* containing the values in the specified range. - -##### *Example* -```php -foreach(['a','b','c','d','e','f','g'] as $c) - $redis->zAdd('key',0,$c); - -$redis->zRangeByLex('key','-','[c') /* ['a','b','c']; */ -$redis->zRangeByLex('key','-','(c') /* ['a','b'] */ -$redis->zRangeByLex('key','-','[c',1,2) /* ['b','c'] */ -``` - -### zRank, zRevRank ------ -_**Description**_: Returns the rank of a given member in the specified sorted set, starting at 0 for the item with the smallest score. zRevRank starts at 0 for the item with the *largest* score. - -##### *Parameters* -*key* -*member* - -##### *Return value* -*Long*, the item's rank. - -##### *Example* -```php -$redis->del('z'); -$redis->zAdd('key', 1, 'one'); -$redis->zAdd('key', 2, 'two'); -$redis->zRank('key', 'one'); /* 0 */ -$redis->zRank('key', 'two'); /* 1 */ -$redis->zRevRank('key', 'one'); /* 1 */ -$redis->zRevRank('key', 'two'); /* 0 */ -``` - -### zRem ------ -_**Description**_: Delete one or more members from a sorted set. - -##### *Prototype* -```php -$redis->zRem($key, $member [, $member ...]); -``` - -##### *Return value* -*LONG:* The number of members deleted. - -##### *Example* -```php -$redis->zAdd('key', 0, 'val0', 1, 'val1', 2, 'val2'); -$redis->zRem('key', 'val0', 'val1', 'val2'); // Returns: 3 -``` - -### zRemRangeByRank ------ -_**Description**_: Deletes the elements of the sorted set stored at the specified key which have rank in the range [start,end]. - -##### *Parameters* -*key* -*start*: LONG -*end*: LONG - -##### *Return value* -*LONG* The number of values deleted from the sorted set - -##### *Example* -```php -$redis->zAdd('key', 1, 'one'); -$redis->zAdd('key', 2, 'two'); -$redis->zAdd('key', 3, 'three'); -$redis->zRemRangeByRank('key', 0, 1); /* 2 */ -$redis->zRange('key', 0, -1, ['withscores' => TRUE]); /* ['three' => 3] */ -``` - -### zRemRangeByScore ------ -_**Description**_: Deletes the elements of the sorted set stored at the specified key which have scores in the range [start,end]. - -##### *Parameters* -*key* -*start*: double or "+inf" or "-inf" string -*end*: double or "+inf" or "-inf" string - -##### *Return value* -*LONG* The number of values deleted from the sorted set - -##### *Example* -```php -$redis->zAdd('key', 0, 'val0'); -$redis->zAdd('key', 2, 'val2'); -$redis->zAdd('key', 10, 'val10'); -$redis->zRemRangeByScore('key', 0, 3); /* 2 */ -``` - -### zRevRange ------ -_**Description**_: Returns the elements of the sorted set stored at the specified key in the range [start, end] in reverse order. start and stop are interpreted as zero-based indices: -`0` the first element, `1` the second ... -`-1` the last element, `-2` the penultimate ... - -##### *Parameters* -*key* -*start*: long -*end*: long -*withscores*: bool = false - -##### *Return value* -*Array* containing the values in specified range. - -##### *Example* -```php -$redis->zAdd('key', 0, 'val0'); -$redis->zAdd('key', 2, 'val2'); -$redis->zAdd('key', 10, 'val10'); -$redis->zRevRange('key', 0, -1); /* ['val10', 'val2', 'val0'] */ - -// with scores -$redis->zRevRange('key', 0, -1, true); /* ['val10' => 10, 'val2' => 2, 'val0' => 0] */ -``` - -### zScore ------ -_**Description**_: Returns the score of a given member in the specified sorted set. - -##### *Parameters* -*key* -*member* - -##### *Return value* -*Double* or *FALSE* when the value is not found - -##### *Example* -```php -$redis->zAdd('key', 2.5, 'val2'); -$redis->zScore('key', 'val2'); /* 2.5 */ -``` - -### zUnion ------ -_**Description**_: Creates an union of sorted sets given in first argument. The result of the union will be returned. - -The second optional argument defines `weights` to apply to the sorted sets in input. In this case, the `weights` will be multiplied by the score of each element in the sorted set before applying the aggregation. -The third argument is a set of options. It can define the `AGGREGATE` option which specify how the results of the intersection are aggregated. It can also define `WITHSCORES` so that the scores are returned as well. - -##### *Parameters* -*arrayZSetKeys* -*arrayWeights* -*arrayOptions* Two options are available: `withscores => TRUE`, and `aggregate => $behaviour`. Either "SUM", "MIN", or "MAX" defines the behaviour to use on duplicate entries during the zunion. - -##### *Return value* -*ARRAY* The result of the union of sets. - -##### *Example* -```php -$redis->del('k1'); -$redis->del('k2'); -$redis->del('k3'); - -$redis->zAdd('k1', 0, 'val0'); -$redis->zAdd('k1', 1, 'val1'); - -$redis->zAdd('k2', 2, 'val2'); -$redis->zAdd('k2', 3, 'val3'); - -$redis->zunion(['k1', 'k2']); /* ['val0', 'val1', 'val2', 'val3'] */ - -/* Weighted zunion */ -$redis->zunion(['k1', 'k2'], [1, 1]); /* ['val0', 'val1', 'val2', 'val3'] */ -$redis->zunion(['k1', 'k2'], [5, 1]); /* ['val0', 'val2', 'val3', 'val1'] */ -``` - -### zunionstore ------ -_**Description**_: Creates an union of sorted sets given in second argument. The result of the union will be stored in the sorted set defined by the first argument. - -The third optional argument defines `weights` to apply to the sorted sets in input. In this case, the `weights` will be multiplied by the score of each element in the sorted set before applying the aggregation. -The forth argument defines the `AGGREGATE` option which specify how the results of the union are aggregated. - -##### *Parameters* -*keyOutput* -*arrayZSetKeys* -*arrayWeights* -*aggregateFunction* Either "SUM", "MIN", or "MAX": defines the behaviour to use on duplicate entries during the zunionstore. - -##### *Return value* -*LONG* The number of values in the new sorted set. - -##### *Example* -```php -$redis->del('k1'); -$redis->del('k2'); -$redis->del('k3'); -$redis->del('ko1'); -$redis->del('ko2'); -$redis->del('ko3'); - -$redis->zAdd('k1', 0, 'val0'); -$redis->zAdd('k1', 1, 'val1'); - -$redis->zAdd('k2', 2, 'val2'); -$redis->zAdd('k2', 3, 'val3'); - -$redis->zunionstore('ko1', ['k1', 'k2']); /* 4, 'ko1' => ['val0', 'val1', 'val2', 'val3'] */ - -/* Weighted zunionstore */ -$redis->zunionstore('ko2', ['k1', 'k2'], [1, 1]); /* 4, 'ko2' => ['val0', 'val1', 'val2', 'val3'] */ -$redis->zunionstore('ko3', ['k1', 'k2'], [5, 1]); /* 4, 'ko3' => ['val0', 'val2', 'val3', 'val1'] */ -``` - -### zScan ------ -_**Description**_: Scan a sorted set for members, with optional pattern and count - -##### *Parameters* -*key*: String, the set to scan -*iterator*: Long (reference), initialized to NULL -*pattern*: String (optional), the pattern to match -*count*: How many keys to return per iteration (Redis might return a different number) - -##### *Return value* -*Array, boolean* PHPRedis will return matching keys from Redis, or FALSE when iteration is complete - -##### *Example* -```php -$it = NULL; -$redis->setOption(Redis::OPT_SCAN, Redis::SCAN_RETRY); -while($arr_matches = $redis->zScan('zset', $it, '*pattern*')) { - foreach($arr_matches as $str_mem => $f_score) { - echo "Key: $str_mem, Score: $f_score\n"; - } -} -``` - -## HyperLogLogs - -### pfAdd ------ - -_**Description**_: Adds the specified elements to the specified HyperLogLog. - -##### *Prototype* -```php -$redis->pfAdd($key, Array $elements); -``` - -##### *Parameters* -_Key_ -_Array of values_ - -##### *Return value* -*Integer*: 1 if at least 1 HyperLogLog internal register was altered. 0 otherwise. - -##### *Example* -```php -$redis->pfAdd('hll', ['a', 'b', 'c']); // (int) 1 -$redis->pfAdd('hll', ['a', 'b']); // (int) 0 -``` - -### pfCount ------ - -_**Description**_: Return the approximated cardinality of the set(s) observed by the HyperLogLog at key(s). - -##### *Prototype* -```php -$redis->pfCount($key); -$redis->pfCount(Array $keys); -``` - -##### *Parameters* -_Key_ or _Array of keys_ - -##### *Return value* -*Integer*: The approximated number of unique elements observed via [pfAdd](#pfAdd). - -##### *Example* -```php -$redis->pfAdd('hll1', ['a', 'b', 'c']); // (int) 1 -$redis->pfCount('hll1'); // (int) 3 - -$redis->pfAdd('hll2', ['d', 'e', 'a']); // (int) 1 -$redis->pfCount('hll2'); // (int) 3 - -$redis->pfCount(['hll1', 'hll2']); // (int) 5 -``` - -### pfMerge ------ - -_**Description**_: Merge N different HyperLogLogs into a single one. - -##### *Prototype* -```php -$redis->pfMerge($destkey, Array $sourceKeys); -``` - -##### *Parameters* -_Destination Key_ -_Array of Source Keys_ - -##### *Return value* -*BOOL*: `TRUE` on success, `FALSE` on error. - -##### *Example* -```php -$redis->pfAdd('hll1', ['a', 'b', 'c']); // (int) 1 -$redis->pfAdd('hll2', ['d', 'e', 'a']); // (int) 1 - -$redis->pfMerge('hll3', ['hll1', 'hll2']); // true - -$redis->pfCount('hll3'); // (int) 5 -``` - -## Geocoding - -### geoAdd ------ - -##### *Prototype* -```php -$redis->geoAdd($key, $longitude, $latitude, $member [, $longitude, $latitude, $member, ...]); -``` - -_**Description**_: Add one or more geospatial items to the specified key. This function must be called with at least one _longitude, latitude, member_ triplet. - -##### *Return value* -*Integer*: The number of elements added to the geospatial key. - -##### *Example* -```php -$redis->del("myplaces"); - -/* Since the key will be new, $result will be 2 */ -$result = $redis->geoAdd( - "myplaces", - -122.431, 37.773, "San Francisco", - -157.858, 21.315, "Honolulu" -); -``` - -### geoHash ------ - -##### *Prototype* -```php -$redis->geoHash($key, $member [, $member, $member, ...]); -``` - -_**Description**_: Retrieve Geohash strings for one or more elements of a geospatial index. - -##### *Return value* -*Array*: One or more Redis Geohash encoded strings. - -##### *Example* -```php -$redis->geoAdd("hawaii", -157.858, 21.306, "Honolulu", -156.331, 20.798, "Maui"); -$hashes = $redis->geoHash("hawaii", "Honolulu", "Maui"); -var_dump($hashes); -``` - -##### *Output* -``` -array(2) { - [0]=> - string(11) "87z9pyek3y0" - [1]=> - string(11) "8e8y6d5jps0" -} -``` - -### geoPos ------ - -##### *Prototype* -```php -$redis->geoPos($key, $member [, $member, $member, ...]); -``` - -_**Description**_: Return longitude, latitude positions for each requested member. - -##### *Return value* -*Array*: One or more longitude/latitude positions - -##### *Example* -```php -$redis->geoAdd("hawaii", -157.858, 21.306, "Honolulu", -156.331, 20.798, "Maui"); -$positions = $redis->geoPos("hawaii", "Honolulu", "Maui"); -var_dump($positions); -``` - -##### *Output* -``` -array(2) { - [0]=> - array(2) { - [0]=> - string(22) "-157.85800248384475708" - [1]=> - string(19) "21.3060004581273077" - } - [1]=> - array(2) { - [0]=> - string(22) "-156.33099943399429321" - [1]=> - string(20) "20.79799924753607598" - } -} -``` - -### GeoDist ------ - -##### *Prototype* -```php -$redis->geoDist($key, $member1, $member2 [, $unit]); -``` - - -_**Description**_: Return the distance between two members in a geospatial set. If units are passed it must be one of the following values: - -* 'm' => Meters -* 'km' => Kilometers -* 'mi' => Miles -* 'ft' => Feet - -##### *Return value* -*Double*: The distance between the two passed members in the units requested (meters by default). - -##### *Example* -```php -$redis->geoAdd("hawaii", -157.858, 21.306, "Honolulu", -156.331, 20.798, "Maui"); - -$meters = $redis->geoDist("hawaii", "Honolulu", "Maui"); -$kilometers = $redis->geoDist("hawaii", "Honolulu", "Maui", 'km'); -$miles = $redis->geoDist("hawaii", "Honolulu", "Maui", 'mi'); -$feet = $redis->geoDist("hawaii", "Honolulu", "Maui", 'ft'); - -echo "Distance between Honolulu and Maui:\n"; -echo " meters : $meters\n"; -echo " kilometers: $kilometers\n"; -echo " miles : $miles\n"; -echo " feet : $feet\n"; - -/* Bad unit */ -$inches = $redis->geoDist("hawaii", "Honolulu", "Maui", 'in'); -echo "Invalid unit returned:\n"; -var_dump($inches); -``` - -##### *Output* -``` -Distance between Honolulu and Maui: - meters : 168275.204 - kilometers: 168.2752 - miles : 104.5616 - feet : 552084.0028 -Invalid unit returned: -bool(false) -``` - -### geoRadius ------ - -##### *Prototype* -```php -$redis->geoRadius($key, $longitude, $latitude, $radius, $unit [, Array $options]); -``` - -_**Description**_: Return members of a set with geospatial information that are within the radius specified by the caller. - -##### *Options Array* -The georadius command can be called with various options that control how Redis returns results. The following table describes the options phpredis supports. All options are case insensitive. - -| Key | Value | Description -| :--- | :--- | :---- | -| COUNT | integer > 0 | Limit how many results are returned -| | WITHCOORD | Return longitude and latitude of matching members -| | WITHDIST | Return the distance from the center -| | WITHHASH | Return the raw geohash-encoded score -| | ASC | Sort results in ascending order -| | DESC | Sort results in descending order -| STORE | _key_ | Store results in _key_ -| STOREDIST | _key_ | Store the results as distances in _key_ - - *Note*: It doesn't make sense to pass both `ASC` and `DESC` options but if both are passed the last one passed will be used. - *Note*: When using `STORE[DIST]` in Redis Cluster, the store key must has to the same slot as the query key or you will get a `CROSSLOT` error. - -##### *Return value* -*Mixed*: When no `STORE` option is passed, this function returns an array of results. If it is passed this function returns the number of stored entries. - -##### *Example* -```php -/* Add some cities */ -$redis->geoAdd("hawaii", -157.858, 21.306, "Honolulu", -156.331, 20.798, "Maui"); - -echo "Within 300 miles of Honolulu:\n"; -var_dump($redis->geoRadius("hawaii", -157.858, 21.306, 300, 'mi')); - -echo "\nWithin 300 miles of Honolulu with distances:\n"; -$options = ['WITHDIST']; -var_dump($redis->geoRadius("hawaii", -157.858, 21.306, 300, 'mi', $options)); - -echo "\nFirst result within 300 miles of Honolulu with distances:\n"; -$options['count'] = 1; -var_dump($redis->geoRadius("hawaii", -157.858, 21.306, 300, 'mi', $options)); - -echo "\nFirst result within 300 miles of Honolulu with distances in descending sort order:\n"; -$options[] = 'DESC'; -var_dump($redis->geoRadius("hawaii", -157.858, 21.306, 300, 'mi', $options)); -``` - -##### *Output* -``` -Within 300 miles of Honolulu: -array(2) { - [0]=> - string(8) "Honolulu" - [1]=> - string(4) "Maui" -} - -Within 300 miles of Honolulu with distances: -array(2) { - [0]=> - array(2) { - [0]=> - string(8) "Honolulu" - [1]=> - string(6) "0.0002" - } - [1]=> - array(2) { - [0]=> - string(4) "Maui" - [1]=> - string(8) "104.5615" - } -} - -First result within 300 miles of Honolulu with distances: -array(1) { - [0]=> - array(2) { - [0]=> - string(8) "Honolulu" - [1]=> - string(6) "0.0002" - } -} - -First result within 300 miles of Honolulu with distances in descending sort order: -array(1) { - [0]=> - array(2) { - [0]=> - string(4) "Maui" - [1]=> - string(8) "104.5615" - } -} -``` - -### geoRadiusByMember - -##### *Prototype* -```php -$redis->geoRadiusByMember($key, $member, $radius, $units [, Array $options]); -``` - -_**Description**_: This method is identical to [geoRadius](#georadius) except that instead of passing a longitude and latitude as the "source" you pass an existing member in the geospatial set. - -##### *Options Array* -See [geoRadius](#georadius) command for options array. - -##### *Return value* -*Array*: The zero or more entries that are close enough to the member given the distance and radius specified. - -##### *Example* -```php -$redis->geoAdd("hawaii", -157.858, 21.306, "Honolulu", -156.331, 20.798, "Maui"); - -echo "Within 300 miles of Honolulu:\n"; -var_dump($redis->geoRadiusByMember("hawaii", "Honolulu", 300, 'mi')); - -echo "\nFirst match within 300 miles of Honolulu:\n"; -var_dump($redis->geoRadiusByMember("hawaii", "Honolulu", 300, 'mi', ['count' => 1])); -``` - -##### *Output* -``` -Within 300 miles of Honolulu: -array(2) { - [0]=> - string(8) "Honolulu" - [1]=> - string(4) "Maui" -} - -First match within 300 miles of Honolulu: -array(1) { - [0]=> - string(8) "Honolulu" -} -``` - -## Streams - -* [xAck](#xack) - Acknowledge one or more pending messages -* [xAdd](#xadd) - Add a message to a stream -* [xClaim](#xclaim) - Acquire ownership of a pending message -* [xDel](#xdel) - Remove a message from a stream -* [xGroup](#xgroup) - Manage consumer groups -* [xInfo](#xinfo) - Get information about a stream -* [xLen](#xlen) - Get the length of a stream -* [xPending](#xpending) - Inspect pending messages in a stream -* [xRange](#xrange) - Query a range of messages from a stream -* [xRead](#xread) - Read message(s) from a stream -* [xReadGroup](#xreadgroup) - Read stream messages with a group and consumer -* [xRevRange](#xrevrange) - Query one or more messages from end to start -* [xTrim](#xtrim) - Trim a stream's size - -### xAck ------ - -##### *Prototype* -```php -$obj_redis->xAck($stream, $group, $arr_messages); -``` - -_**Description**_: Acknowledge one or more messages on behalf of a consumer group. - -##### *Return value* -*long*: The number of messages Redis reports as acknowledged. - -##### *Example* -```php -$obj_redis->xAck('stream', 'group1', ['1530063064286-0', '1530063064286-1']); -``` - -### xAdd ------ - -##### *Prototype* -```php -$obj_redis->xAdd($str_key, $str_id, $arr_message[, $i_maxlen, $boo_approximate]); -``` - -_**Description**_: Add a message to a stream - -##### *Return value* -*String*: The added message ID - -##### *Example* -```php -$obj_redis->xAdd('mystream', "*", ['field' => 'value']); -$obj_redis->xAdd('mystream', "*", ['field' => 'value'], 1000); // set max length of stream to 1000 -$obj_redis->xAdd('mystream', "*", ['field' => 'value'], 1000, true); // set max length of stream to ~1000 -``` - -### xClaim ------ - -##### *Prototype* -```php -$obj_redis->xClaim($str_key, $str_group, $str_consumer, $min_idle_time, $arr_ids, [$arr_options]); -``` - -_**Description**_: Claim ownership of one or more pending messages. - -#### *Options Array* -```php -$options = [ - /* Note: 'TIME', and 'IDLE' are mutually exclusive */ - 'IDLE' => $value, /* Set the idle time to $value ms */, - 'TIME' => $value, /* Set the idle time to now - $value */ - 'RETRYCOUNT' => $value, /* Update message retrycount to $value */ - 'FORCE', /* Claim the message(s) even if they're not pending anywhere */ - 'JUSTID', /* Instruct Redis to only return IDs */ -]; -``` - -##### *Return value* -*Array*: Either an array of message IDs along with corresponding data, or just an array of IDs (if the 'JUSTID' option was passed). - -##### *Example* -```php -$ids = ['1530113681011-0', '1530113681011-1', '1530113681011-2']; - -/* Without any options */ -$obj_redis->xClaim( - 'mystream', 'group1', 'myconsumer1', 0, $ids -); - -/* With options */ -$obj_redis->xClaim( - 'mystream', 'group1', 'myconsumer2', 0, $ids, - [ - 'IDLE' => time() * 1000, - 'RETRYCOUNT' => 5, - 'FORCE', - 'JUSTID' - ] -); -``` - -### xDel ------ - -##### *Prototype* -```php -$obj_redis->xDel($str_key, $arr_ids); -``` - -_**Description**_: Delete one or more messages from a stream. - -##### *Return value* -*long*: The number of messages removed - -##### *Example* -```php -$obj_redis->xDel('mystream', ['1530115304877-0', '1530115305731-0']); -``` - -### xGroup ------ - -##### *Prototype* -```php -$obj_redis->xGroup('HELP'); -$obj_redis->xGroup('CREATE', $str_key, $str_group, $str_msg_id, [$boo_mkstream]); -$obj_redis->xGroup('SETID', $str_key, $str_group, $str_msg_id); -$obj_redis->xGroup('DESTROY', $str_key, $str_group); -$obj_redis->xGroup('DELCONSUMER', $str_key, $str_group, $str_consumer_name); -``` - -_**Description**_: This command is used in order to create, destroy, or manage consumer groups. - -##### *Return value* -*Mixed*: This command returns different types depending on the specific XGROUP command executed. - -##### *Example* -```php -$obj_redis->xGroup('CREATE', 'mystream', 'mygroup', '0'); -$obj_redis->xGroup('CREATE', 'mystream', 'mygroup2', '0', true); /* Create stream if non-existent. */ -$obj_redis->xGroup('DESTROY', 'mystream', 'mygroup'); -``` - -### xInfo ------ - -##### *Prototype* -```php -$obj_redis->xInfo('CONSUMERS', $str_stream, $str_group); -$obj_redis->xInfo('GROUPS', $str_stream); -$obj_redis->xInfo('STREAM', $str_stream [, 'FULL' [, $i_count]]); -$obj_redis->xInfo('HELP'); -``` - -_**Description**_: Get information about a stream or consumer groups. - -##### *Return value* -*Mixed*: This command returns different types depending on which subcommand is used. - -##### *Example* -```php -$obj_redis->xInfo('STREAM', 'mystream'); -$obj_redis->xInfo('STREAM', 'mystream', 'FULL', 10); -``` - -### xLen ------ - -##### *Prototype* -```php -$obj_redis->xLen($str_stream); -``` - -_**Description**_: Get the length of a given stream - -##### *Return value* -*Long*: The number of messages in the stream. - -##### *Example* -```php -$obj_redis->xLen('mystream'); -``` - -### xPending ------ - -##### *Prototype* -```php -$obj_redis->xPending($str_stream, $str_group [, $str_start, $str_end, $i_count, $str_consumer]); -``` - -_**Description**_: Get information about pending messages in a given stream. - -##### *Return value* -*Array*: Information about the pending messages, in various forms depending on the specific invocation of XPENDING. - -##### *Examples* -```php -$obj_redis->xPending('mystream', 'mygroup'); -$obj_redis->xPending('mystream', 'mygroup', '-', '+', 1, 'consumer-1'); -``` - -### xRange ------ - -##### *Prototype* -```php -$obj_redis->xRange($str_stream, $str_start, $str_end [, $i_count]); -``` - -_**Description**_: Get a range of messages from a given stream. - -##### *Return value* -*Array*: The messages in the stream within the requested range. - -##### *Example* -```php -/* Get everything in this stream */ -$obj_redis->xRange('mystream', '-', '+'); - -/* Only the first two messages */ -$obj_redis->xRange('mystream', '-', '+', 2); -``` - -### xRead ------ - -##### *Prototype* -```php -$obj_redis->xRead($arr_streams [, $i_count, $i_block]); -``` - -_**Description**_: Read data from one or more streams and only return IDs greater than sent in the command. - -##### *Return value* -*Array*: The messages in the stream newer than the IDs passed to Redis (if any). - -##### *Example* -```php -$obj_redis->xRead(['stream1' => '1535222584555-0', 'stream2' => '1535222584555-0']); - -/* --- Possible output --- -Array -( - [stream1] => Array - ( - [1535222584555-1] => Array - ( - [key:1] => val:1 - ) - - ) - - [stream2] => Array - ( - [1535222584555-1] => Array - ( - [key:1] => val:1 - ) - - ) - -) -*/ - -// Receive only new message ($ = last id) and wait for one new message unlimited time -$obj_redis->xRead(['stream1' => '$'], 1, 0); -``` - -### xReadGroup ------ - -##### *Prototype* -```php -$obj_redis->xReadGroup($str_group, $str_consumer, $arr_streams [, $i_count, $i_block]); -``` - -_**Description**_: This method is similar to xRead except that it supports reading messages for a specific consumer group. - -##### *Return value* -*Array*: The messages delivered to this consumer group (if any). - -##### *Examples* -```php -/* Consume messages for 'mygroup', 'consumer1' */ -$obj_redis->xReadGroup('mygroup', 'consumer1', ['s1' => 0, 's2' => 0]); - -/* Consume messages for 'mygroup', 'consumer1' which were not consumed yet by the group */ -$obj_redis->xReadGroup('mygroup', 'consumer1', ['s1' => '>', 's2' => '>']); - -/* Read a single message as 'consumer2' wait for up to a second until a message arrives. */ -$obj_redis->xReadGroup('mygroup', 'consumer2', ['s1' => 0, 's2' => 0], 1, 1000); -``` - -### xRevRange ------ - -##### *Prototype* -```php -$obj_redis->xRevRange($str_stream, $str_end, $str_start [, $i_count]); -``` - -_**Description**_: This is identical to xRange except the results come back in reverse order. Also note that Redis reverses the order of "start" and "end". - -##### *Return value* -*Array*: The messages in the range specified. - -##### *Example* -```php -$obj_redis->xRevRange('mystream', '+', '-'); -``` - -### xTrim ------ - -##### *Prototype* -```php -$obj_redis->xTrim($str_stream, $i_max_len [, $boo_approximate]); -``` - -_**Description**_: Trim the stream length to a given maximum. If the "approximate" flag is pasesed, Redis will use your size as a hint but only trim trees in whole nodes (this is more efficient). - -##### *Return value* -*long*: The number of messages trimmed from the stream. - -##### *Example* -```php -/* Trim to exactly 100 messages */ -$obj_redis->xTrim('mystream', 100); - -/* Let Redis approximate the trimming */ -$obj_redis->xTrim('mystream', 100, true); -``` - -## Pub/sub - -* [pSubscribe](#psubscribe) - Subscribe to channels by pattern -* [publish](#publish) - Post a message to a channel -* [subscribe](#subscribe) - Subscribe to channels -* [pubSub](#pubsub) - Introspection into the pub/sub subsystem - -### pSubscribe ------ -_**Description**_: Subscribe to channels by pattern - -##### *Parameters* -*patterns*: An array of patterns to match -*callback*: Either a string or an array with an object and method. The callback will get four arguments ($redis, $pattern, $channel, $message) -*return value*: Mixed. Any non-null return value in the callback will be returned to the caller. -##### *Example* -```php -function pSubscribe($redis, $pattern, $chan, $msg) { - echo "Pattern: $pattern\n"; - echo "Channel: $chan\n"; - echo "Payload: $msg\n"; -} -``` - -### publish ------ -_**Description**_: Publish messages to channels. Warning: this function will probably change in the future. - -##### *Parameters* -*channel*: a channel to publish to -*message*: string - -##### *Example* -```php -$redis->publish('chan-1', 'hello, world!'); // send message. -``` - -### subscribe ------ -_**Description**_: Subscribe to channels. Warning: this function will probably change in the future. - -##### *Parameters* -*channels*: an array of channels to subscribe to -*callback*: either a string or [$instance, 'method_name']. The callback function receives 3 parameters: the redis instance, the channel name, and the message. -*return value*: Mixed. Any non-null return value in the callback will be returned to the caller. -##### *Example* -```php -function f($redis, $chan, $msg) { - switch($chan) { - case 'chan-1': - ... - break; - - case 'chan-2': - ... - break; - - case 'chan-2': - ... - break; - } -} - -$redis->subscribe(['chan-1', 'chan-2', 'chan-3'], 'f'); // subscribe to 3 chans -``` - -### pubSub ------ -_**Description**_: A command allowing you to get information on the Redis pub/sub system. - -##### *Parameters* -*keyword*: String, which can be: "channels", "numsub", or "numpat" -*argument*: Optional, variant. For the "channels" subcommand, you can pass a string pattern. For "numsub" an array of channel names. - -##### *Return value* -*CHANNELS*: Returns an array where the members are the matching channels. -*NUMSUB*: Returns a key/value array where the keys are channel names and values are their counts. -*NUMPAT*: Integer return containing the number active pattern subscriptions - -##### *Example* -```php -$redis->pubSub("channels"); /*All channels */ -$redis->pubSub("channels", "*pattern*"); /* Just channels matching your pattern */ -$redis->pubSub("numsub", ["chan1", "chan2"]); /*Get subscriber counts for 'chan1' and 'chan2'*/ -$redis->pubSub("numpat"); /* Get the number of pattern subscribers */ - - -``` - -## Generic -1. [rawCommand](#rawcommand) - Execute any generic command against the server. - -### rawCommand ------ -_**Description**_: A method to execute any arbitrary command against the a Redis server - -##### *Parameters* -This method is variadic and takes a dynamic number of arguments of various types (string, long, double), but must be passed at least one argument (the command keyword itself). - -##### *Return value* -The return value can be various types depending on what the server itself returns. No post processing is done to the returned value and must be handled by the client code. - -##### *Example* -```php -/* Returns: true */ -$redis->rawCommand("set", "foo", "bar"); - -/* Returns: "bar" */ -$redis->rawCommand("get", "foo"); - -/* Returns: 3 */ -$redis->rawCommand("rpush", "mylist", "one", 2, 3.5); - -/* Returns: ["one", "2", "3.5000000000000000"] */ -$redis->rawCommand("lrange", "mylist", 0, -1); -``` - -## Transactions - -1. [multi, exec, discard](#multi-exec-discard) - Enter and exit transactional mode -2. [watch, unwatch](#watch-unwatch) - Watches a key for modifications by another client. - -### multi, exec, discard. ------ -_**Description**_: Enter and exit transactional mode. - -##### *Parameters* -(optional) `Redis::MULTI` or `Redis::PIPELINE`. Defaults to `Redis::MULTI`. A `Redis::MULTI` block of commands runs as a single transaction; a `Redis::PIPELINE` block is simply transmitted faster to the server, but without any guarantee of atomicity. `discard` cancels a transaction. - -##### *Return value* -`multi()` returns the Redis instance and enters multi-mode. Once in multi-mode, all subsequent method calls return the same object until `exec()` is called. - -##### *Example* -```php -$ret = $redis->multi() - ->set('key1', 'val1') - ->get('key1') - ->set('key2', 'val2') - ->get('key2') - ->exec(); - -/* -$ret == [0 => TRUE, 1 => 'val1', 2 => TRUE, 3 => 'val2']; -*/ -``` - -### watch, unwatch ------ -_**Description**_: Watches a key for modifications by another client. - -If the key is modified between `WATCH` and `EXEC`, the MULTI/EXEC transaction will fail (return `FALSE`). `unwatch` cancels all the watching of all keys by this client. - -##### *Parameters* -*keys*: string for one key or array for a list of keys - -##### *Example* -```php -$redis->watch('x'); // or for a list of keys: $redis->watch(['x','another key']); -/* long code here during the execution of which other clients could well modify `x` */ -$ret = $redis->multi() - ->incr('x') - ->exec(); -/* -$ret = FALSE if x has been modified between the call to WATCH and the call to EXEC. -*/ -``` - - - -## Scripting - -* [eval](#eval) - Evaluate a LUA script serverside -* [evalSha](#evalsha) - Evaluate a LUA script serverside, from the SHA1 hash of the script instead of the script itself -* [script](#script) - Execute the Redis SCRIPT command to perform various operations on the scripting subsystem -* [getLastError](#getlasterror) - The last error message (if any) -* [clearLastError](#clearlasterror) - Clear the last error message -* [_prefix](#_prefix) - A utility method to prefix the value with the prefix setting for phpredis -* [_unserialize](#_unserialize) - A utility method to unserialize data with whatever serializer is set up -* [_serialize](#_serialize) - A utility method to serialize data with whatever serializer is set up - -### eval ------ -_**Description**_: Evaluate a LUA script serverside - -##### *Parameters* -*script* string. -*args* array, optional. -*num_keys* int, optional. - -##### *Return value* -Mixed. What is returned depends on what the LUA script itself returns, which could be a scalar value (int/string), or an array. -Arrays that are returned can also contain other arrays, if that's how it was set up in your LUA script. If there is an error -executing the LUA script, the getLastError() function can tell you the message that came back from Redis (e.g. compile error). - -##### *Examples* -```php -$redis->eval("return 1"); // Returns an integer: 1 -$redis->eval("return {1,2,3}"); // Returns [1,2,3] -$redis->del('mylist'); -$redis->rpush('mylist','a'); -$redis->rpush('mylist','b'); -$redis->rpush('mylist','c'); -// Nested response: [1,2,3,['a','b','c']]; -$redis->eval("return {1,2,3,redis.call('lrange','mylist',0,-1)}"); -``` - -### evalSha ------ -_**Description**_: Evaluate a LUA script serverside, from the SHA1 hash of the script instead of the script itself. - -In order to run this command Redis will have to have already loaded the script, -either by running it or via the SCRIPT LOAD command. - -##### *Parameters* -*script_sha* string. The sha1 encoded hash of the script you want to run. -*args* array, optional. Arguments to pass to the LUA script. -*num_keys* int, optional. The number of arguments that should go into the KEYS array, vs. the ARGV array when Redis spins the script - -##### *Return value* -Mixed. See EVAL - -##### *Examples* -```php -$script = 'return 1'; -$sha = $redis->script('load', $script); -$redis->evalSha($sha); // Returns 1 -``` - -### script ------ -_**Description**_: Execute the Redis SCRIPT command to perform various operations on the scripting subsystem. - -##### *Usage* -```php -$redis->script('load', $script); -$redis->script('flush'); -$redis->script('kill'); -$redis->script('exists', $script1, [$script2, $script3, ...]); -``` - -##### *Return value* -* SCRIPT LOAD will return the SHA1 hash of the passed script on success, and FALSE on failure. -* SCRIPT FLUSH should always return TRUE -* SCRIPT KILL will return true if a script was able to be killed and false if not -* SCRIPT EXISTS will return an array with TRUE or FALSE for each passed script - -### client ------ -_**Description**_: Issue the CLIENT command with various arguments. - -The Redis CLIENT command can be used in four ways. -* CLIENT LIST -* CLIENT GETNAME -* CLIENT SETNAME [name] -* CLIENT KILL [ip:port] - -##### *Usage* -```php -$redis->client('list'); // Get a list of clients -$redis->client('getname'); // Get the name of the current connection -$redis->client('setname', 'somename'); // Set the name of the current connection -$redis->client('kill', ); // Kill the process at ip:port -``` - -##### *Return value* -This will vary depending on which client command was executed. - -* CLIENT LIST will return an array of arrays with client information. -* CLIENT GETNAME will return the client name or false if none has been set -* CLIENT SETNAME will return true if it can be set and false if not -* CLIENT KILL will return true if the client can be killed, and false if not - -Note: phpredis will attempt to reconnect so you can actually kill your own connection -but may not notice losing it! -### getLastError ------ -_**Description**_: The last error message (if any) - -##### *Parameters* -*none* - -##### *Return value* -A string with the last returned script based error message, or NULL if there is no error - -##### *Examples* -```php -$redis->eval('this-is-not-lua'); -$err = $redis->getLastError(); -// "ERR Error compiling script (new function): user_script:1: '=' expected near '-'" -``` - -### clearLastError ------ -_**Description**_: Clear the last error message - -##### *Parameters* -*none* - -##### *Return value* -*BOOL* TRUE - -##### *Examples* -```php -$redis->set('x', 'a'); -$redis->incr('x'); -$err = $redis->getLastError(); -// "ERR value is not an integer or out of range" -$redis->clearLastError(); -$err = $redis->getLastError(); -// NULL -``` - -### _prefix ------ -_**Description**_: A utility method to prefix the value with the prefix setting for phpredis. - -##### *Parameters* -*value* string. The value you wish to prefix - -##### *Return value* -If a prefix is set up, the value now prefixed. If there is no prefix, the value will be returned unchanged. - -##### *Examples* -```php -$redis->setOption(Redis::OPT_PREFIX, 'my-prefix:'); -$redis->_prefix('my-value'); // Will return 'my-prefix:my-value' -``` - -### _serialize ------ -_**Description**_: A utility method to serialize values manually. - -This method allows you to serialize a value with whatever serializer is configured, manually. -This can be useful for serialization/unserialization of data going in and out of EVAL commands -as phpredis can't automatically do this itself. Note that if no serializer is set, phpredis -will change Array values to 'Array', and Objects to 'Object'. - -##### *Parameters* -*value*: Mixed. The value to be serialized - -##### *Examples* -```php -$redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_NONE); -$redis->_serialize("foo"); // returns "foo" -$redis->_serialize([]); // Returns "Array" -$redis->_serialize(new stdClass()); // Returns "Object" - -$redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP); -$redis->_serialize("foo"); // Returns 's:3:"foo";' -``` - -### _unserialize ------ -_**Description**_: A utility method to unserialize data with whatever serializer is set up. - -If there is no serializer set, the value will be returned unchanged. If there is a serializer set up, -and the data passed in is malformed, an exception will be thrown. This can be useful if phpredis is -serializing values, and you return something from redis in a LUA script that is serialized. - -##### *Parameters* -*value* string. The value to be unserialized - -##### *Examples* -```php -$redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP); -$redis->_unserialize('a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}'); // Will return [1,2,3] -``` - - - -## Introspection - -### isConnected ------ -_**Description**_: A method to determine if a phpredis object thinks it's connected to a server - -##### *Parameters* -None - -##### *Return value* -*Boolean* Returns TRUE if phpredis thinks it's connected and FALSE if not - -### getHost ------ -_**Description**_: Retrieve our host or unix socket that we're connected to - -##### *Parameters* -None - -##### *Return value* -*Mixed* The host or unix socket we're connected to or FALSE if we're not connected - - -### getPort ------ -_**Description**_: Get the port we're connected to - -##### *Parameters* -None - -##### *Return value* -*Mixed* Returns the port we're connected to or FALSE if we're not connected - -### getDbNum ------ -_**Description**_: Get the database number phpredis is pointed to - -##### *Parameters* -None - -##### *Return value* -*Mixed* Returns the database number (LONG) phpredis thinks it's pointing to or FALSE if we're not connected - -### getTimeout ------ -_**Description**_: Get the (write) timeout in use for phpredis - -##### *Parameters* -None - -##### *Return value* -*Mixed* The timeout (DOUBLE) specified in our connect call or FALSE if we're not connected - -### getReadTimeout -_**Description**_: Get the read timeout specified to phpredis or FALSE if we're not connected - -##### *Parameters* -None - -##### *Return value* -*Mixed* Returns the read timeout (which can be set using setOption and Redis::OPT_READ_TIMEOUT) or FALSE if we're not connected - -### getPersistentID ------ -_**Description**_: Gets the persistent ID that phpredis is using - -##### *Parameters* -None - -##### *Return value* -*Mixed* Returns the persistent id phpredis is using (which will only be set if connected with pconnect), NULL if we're not -using a persistent ID, and FALSE if we're not connected - -### getAuth ------ -_**Description**_: Get the password (or username and password if using Redis 6 ACLs) used to authenticate the connection. - -### *Parameters* -None - -### *Return value* -*Mixed* Returns NULL if no username/password are set, the password string if a password is set, and a `[username, password]` array if authenticated with a username and password. +- GitHub Issues +- Discord Community +- Stack Overflow diff --git a/arrays.md b/arrays.md index b5ba3738cf..157e37ec49 100644 --- a/arrays.md +++ b/arrays.md @@ -1,23 +1,23 @@ -Redis Arrays +Valkey Arrays ============ -A Redis array is an isolated namespace in which keys are related in some manner. Keys are distributed across a number of Redis instances, using consistent hashing. A hash function is used to spread the keys across the array in order to keep a uniform distribution. **This feature was added as the result of a generous sponsorship by [A+E Networks](http://www.aetn.com/).** +A Valkey array is an isolated namespace in which keys are related in some manner. Keys are distributed across a number of Valkey instances, using consistent hashing. A hash function is used to spread the keys across the array in order to keep a uniform distribution. **This feature was added as the result of a generous sponsorship by [A+E Networks](http://www.aetn.com/).** An array is composed of the following: -* A list of Redis hosts. +* A list of Valkey hosts. * A key extraction function, used to hash part of the key in order to distribute related keys on the same node (optional). This is set by the "function" option. * A list of nodes previously in the ring, only present after a node has been added or removed. When a read command is sent to the array (e.g. GET, LRANGE...), the key is first queryied in the main ring, and then in the secondary ring if it was not found in the main one. Optionally, the keys can be migrated automatically when this happens. Write commands will always go to the main ring. This is set by the "previous" option. -* An optional index in the form of a Redis set per node, used to migrate keys when nodes are added or removed; set by the "index" option. +* An optional index in the form of a Valkey set per node, used to migrate keys when nodes are added or removed; set by the "index" option. * An option to rehash the array automatically as nodes are added or removed, set by the "autorehash" option. ## Creating an array -There are several ways of creating Redis arrays; they can be pre-defined in redis.ini using `new RedisArray(string $name);`, or created dynamically using `new RedisArray(array $hosts, array $options);` +There are several ways of creating Valkey arrays; they can be pre-defined in redis.ini using `new ValkeyArray(string $name);`, or created dynamically using `new ValkeyArray(array $hosts, array $options);` #### Declaring a new array with a list of nodes
-$ra = new RedisArray(array("host1", "host2:63792", "host2:6380"));
+$ra = new ValkeyArray(array("host1", "host2:63792", "host2:6380"));
 
@@ -26,67 +26,67 @@ $ra = new RedisArray(array("host1", "host2:63792", "host2:6380")); function extract_key_part($k) { return substr($k, 0, 3); // hash only on first 3 characters. } -$ra = new RedisArray(array("host1", "host2:63792", "host2:6380"), array("function" => "extract_key_part")); +$ra = new ValkeyArray(array("host1", "host2:63792", "host2:6380"), array("function" => "extract_key_part")); #### Defining a "previous" array when nodes are added or removed. -When a new node is added to an array, phpredis needs to know about it. The old list of nodes becomes the “previous” array, and the new list of nodes is used as a main ring. Right after a node has been added, some read commands will point to the wrong nodes and will need to look up the keys in the previous ring. +When a new node is added to an array, valkey-php needs to know about it. The old list of nodes becomes the “previous” array, and the new list of nodes is used as a main ring. Right after a node has been added, some read commands will point to the wrong nodes and will need to look up the keys in the previous ring.
 // adding host3 to a ring containing host1 and host2. Read commands will look in the previous ring if the data is not found in the main ring.
-$ra = new RedisArray(array("host1", "host2", "host3"), array("previous" => array("host1", "host2")));
+$ra = new ValkeyArray(array("host1", "host2", "host3"), array("previous" => array("host1", "host2")));
 
#### Specifying the "retry_interval" parameter The retry_interval is used to specify a delay in milliseconds between reconnection attempts in case the client loses connection with a server
-$ra = new RedisArray(array("host1", "host2:63792", "host2:6380"), array("retry_interval" => 100));
+$ra = new ValkeyArray(array("host1", "host2:63792", "host2:6380"), array("retry_interval" => 100));
 
#### Specifying the "lazy_connect" parameter This option is useful when a cluster has many shards but not of them are necessarily used at one time.
-$ra = new RedisArray(array("host1", "host2:63792", "host2:6380"), array("lazy_connect" => true));
+$ra = new ValkeyArray(array("host1", "host2:63792", "host2:6380"), array("lazy_connect" => true));
 
#### Specifying the "connect_timeout" parameter -The connect_timeout value is a double and is used to specify a timeout in number of seconds when creating redis socket connections used in the RedisArray. +The connect_timeout value is a double and is used to specify a timeout in number of seconds when creating redis socket connections used in the ValkeyArray.
-$ra = new RedisArray(array("host1", "host2:63792", "host2:6380"), array("connect_timeout" => 0.5));
+$ra = new ValkeyArray(array("host1", "host2:63792", "host2:6380"), array("connect_timeout" => 0.5));
 
#### Specifying the "read_timeout" parameter The read_timeout value is a double and is used to specify a timeout in number of seconds when waiting response from the server.
-$ra = new RedisArray(array("host1", "host2:63792", "host2:6380"), array("read_timeout" => 0.5));
+$ra = new ValkeyArray(array("host1", "host2:63792", "host2:6380"), array("read_timeout" => 0.5));
 
#### Specifying the "algorithm" parameter The algorithm value is a string and is used to specify the name of key hashing algorithm. The list of possible values may be found using PHP function `hash_algos`. If algorithm is not supported by PHP `hash` function default algorithm will be used (CRC32 with 0xffffffff initial value).
-$ra = new RedisArray(array("host1", "host2:63792", "host2:6380"), array("algorithm" => "md5"));
+$ra = new ValkeyArray(array("host1", "host2:63792", "host2:6380"), array("algorithm" => "md5"));
 
#### Specifying the "consistent" parameter -The value is boolean. When enabled RedisArray uses "ketama" distribution algorithm (currently without ability to set weight to each server). +The value is boolean. When enabled ValkeyArray uses "ketama" distribution algorithm (currently without ability to set weight to each server). This option applies to main and previous ring if specified.
-$ra = new RedisArray(array("host1", "host2:63792", "host2:6380"), array("consistent" => true));
+$ra = new ValkeyArray(array("host1", "host2:63792", "host2:6380"), array("consistent" => true));
 
#### Specifying the "auth" parameter The value is string and used to specify the password for authenticate with the server prior to sending commands
-$ra = new RedisArray(array("host1", "host2:63792", "host2:6380"), array("auth" => "mysecretpassword"));
+$ra = new ValkeyArray(array("host1", "host2:63792", "host2:6380"), array("auth" => "mysecretpassword"));
 
-#### Defining arrays in Redis.ini +#### Defining arrays in Valkey.ini -Because php.ini parameters must be pre-defined, Redis Arrays must all share the same .ini settings. +Because php.ini parameters must be pre-defined, Valkey Arrays must all share the same .ini settings.
-// list available Redis Arrays
+// list available Valkey Arrays
 ini_set('redis.array.names', 'users,friends');
 
 // set host names for each array.
@@ -104,35 +104,35 @@ ini_set('redis.arrays.auth', 'users=mysecretpassword')
 
 ## Usage
 
-Redis arrays can be used just as Redis objects:
+Valkey arrays can be used just as Valkey objects:
 
-$ra = new RedisArray("users");
+$ra = new ValkeyArray("users");
 $ra->set("user1:name", "Joe");
 $ra->set("user2:name", "Mike");
 
## Key hashing -By default and in order to be compatible with other libraries, phpredis will try to find a substring enclosed in curly braces within the key name, and use it to distribute the data. +By default and in order to be compatible with other libraries, valkey-php will try to find a substring enclosed in curly braces within the key name, and use it to distribute the data. For instance, the keys “{user:1}:name” and “{user:1}:email” will be stored on the same server as only “user:1” will be hashed. You can provide a custom function name in your redis array with the "function" option; this function will be called every time a key needs to be hashed. It should take a string and return a string. ## Custom key distribution function -In order to control the distribution of keys by hand, you can provide a custom function or closure that returns the server number, which is the index in the array of servers that you created the RedisArray object with. +In order to control the distribution of keys by hand, you can provide a custom function or closure that returns the server number, which is the index in the array of servers that you created the ValkeyArray object with. -For instance, instantiate a RedisArray object with `new RedisArray(["us-host", "uk-host", "de-host"], ["distributor" => "dist"]);` and write a function called "dist" that will return `2` for all the keys that should end up on the "de-host" server. +For instance, instantiate a ValkeyArray object with `new ValkeyArray(["us-host", "uk-host", "de-host"], ["distributor" => "dist"]);` and write a function called "dist" that will return `2` for all the keys that should end up on the "de-host" server. ### Example
-$ra = new RedisArray(array("host1", "host2", "host3", "host4", "host5", "host6", "host7", "host8"), array("distributor" => array(2, 2)));
+$ra = new ValkeyArray(array("host1", "host2", "host3", "host4", "host5", "host6", "host7", "host8"), array("distributor" => array(2, 2)));
 
This declares that we started with 2 shards and moved to 4 then 8 shards. The number of initial shards is 2 and the resharding level (or number of iterations) is 2. ## Migrating keys -When a node is added or removed from a ring, RedisArray instances must be instantiated with a “previous” list of nodes. A single call to `$ra->_rehash()` causes all the keys to be redistributed according to the new list of nodes. Passing a callback function to `_rehash()` makes it possible to track the progress of that operation: the function is called with a node name and a number of keys that will be examined, e.g. `_rehash(function ($host, $count){ ... });`. +When a node is added or removed from a ring, ValkeyArray instances must be instantiated with a “previous” list of nodes. A single call to `$ra->_rehash()` causes all the keys to be redistributed according to the new list of nodes. Passing a callback function to `_rehash()` makes it possible to track the progress of that operation: the function is called with a node name and a number of keys that will be examined, e.g. `_rehash(function ($host, $count){ ... });`. It is possible to automate this process, by setting `'autorehash' => TRUE` in the constructor options. This will cause keys to be migrated when they need to be read from the previous array. @@ -143,7 +143,7 @@ Adding and/or removing several instances is supported. ### Example
-$ra = new RedisArray("users"); // load up a new config from redis.ini, using the “.previous” listing.
+$ra = new ValkeyArray("users"); // load up a new config from redis.ini, using the “.previous” listing.
 $ra->_rehash();
 
@@ -165,15 +165,15 @@ $ra->multi($host) // then run transaction on that host.
## Limitations -Key arrays offer no guarantee when using Redis commands that span multiple keys. Except for the use of MGET, MSET, and DEL, a single connection will be used and all the keys read or written there. Running KEYS() on a RedisArray object will execute the command on each node and return an associative array of keys, indexed by host name. +Key arrays offer no guarantee when using Valkey commands that span multiple keys. Except for the use of MGET, MSET, and DEL, a single connection will be used and all the keys read or written there. Running KEYS() on a ValkeyArray object will execute the command on each node and return an associative array of keys, indexed by host name. ## Array info -RedisArray objects provide several methods to help understand the state of the cluster. These methods start with an underscore. +ValkeyArray objects provide several methods to help understand the state of the cluster. These methods start with an underscore. * `$ra->_hosts()` → returns a list of hosts for the selected array. * `$ra->_function()` → returns the name of the function used to extract key parts during consistent hashing. * `$ra->_target($key)` → returns the host to be used for a certain key. -* `$ra->_instance($host)` → returns a redis instance connected to a specific node; use with `_target` to get a single Redis object. +* `$ra->_instance($host)` → returns a redis instance connected to a specific node; use with `_target` to get a single Valkey object. * `$ra->_continuum()` → returns a list of points on continuum; may be useful with custom distributor function. ## Running the unit tests diff --git a/cluster.md b/cluster.md index 731d49949a..b9a8cd5344 100644 --- a/cluster.md +++ b/cluster.md @@ -1,36 +1,36 @@ -Redis Cluster +Valkey Cluster ============= -Redis introduces cluster support as of version 3.0.0, and to communicate with a cluster using phpredis one needs to use the RedisCluster class. For the majority of operations the RedisCluster class can act as a drop-in replacement for the Redis class without needing to modify how it's called. **This feature was added as the result of a generous sponsorship by [Tradesy](https://www.tradesy.com/)** +Valkey introduces cluster support as of version 3.0.0, and to communicate with a cluster using valkey-php one needs to use the ValkeyCluster class. For the majority of operations the ValkeyCluster class can act as a drop-in replacement for the Valkey class without needing to modify how it's called. **This feature was added as the result of a generous sponsorship by [Tradesy](https://www.tradesy.com/)** ## Creating and connecting to a cluster -To maintain consistency with the RedisArray class, one can create and connect to a cluster either by passing it one or more 'seed' nodes, or by defining these in redis.ini as a 'named' cluster. +To maintain consistency with the ValkeyArray class, one can create and connect to a cluster either by passing it one or more 'seed' nodes, or by defining these in redis.ini as a 'named' cluster. #### Declaring a cluster with an array of seeds ```php // Create a cluster setting three nodes as seeds -$obj_cluster = new RedisCluster(NULL, ['host:7000', 'host:7001', 'host:7003']); +$obj_cluster = new ValkeyCluster(NULL, ['host:7000', 'host:7001', 'host:7003']); // Connect and specify timeout and read_timeout -$obj_cluster = new RedisCluster(NULL, ["host:7000", "host:7001"], 1.5, 1.5); +$obj_cluster = new ValkeyCluster(NULL, ["host:7000", "host:7001"], 1.5, 1.5); -// Connect with read/write timeout as well as specify that phpredis should use +// Connect with read/write timeout as well as specify that valkey-php should use // persistent connections to each node. -$obj_cluster = new RedisCluster(NULL, ["host:7000", "host:7001"], 1.5, 1.5, true); +$obj_cluster = new ValkeyCluster(NULL, ["host:7000", "host:7001"], 1.5, 1.5, true); // Connect with cluster using password. -$obj_cluster = new RedisCluster(NULL, ["host:7000", "host:7001"], 1.5, 1.5, true, "password"); +$obj_cluster = new ValkeyCluster(NULL, ["host:7000", "host:7001"], 1.5, 1.5, true, "password"); // Connect with cluster using TLS // last argument is an optional array with [SSL context options](https://www.php.net/manual/en/context.ssl.php) (TLS options) // If value is array (even empty), it will connect via TLS. If not, it will connect without TLS. // Note: If the seeds start with "ssl:// or tls://", it will connect to the seeds via TLS, but the subsequent connections will connect without TLS if this value is null. So, if your nodes require TLS, this value must be an array, even if empty. -$obj_cluster = new RedisCluster(NULL, ["host:7000", "host:7001"], 1.5, 1.5, true, NULL, ["verify_peer" => false]); +$obj_cluster = new ValkeyCluster(NULL, ["host:7000", "host:7001"], 1.5, 1.5, true, NULL, ["verify_peer" => false]); ``` #### Loading a cluster configuration by name -In order to load a named array, one must first define the seed nodes in redis.ini. The following lines would define the cluster 'mycluster', and be loaded automatically by phpredis. +In order to load a named array, one must first define the seed nodes in redis.ini. The following lines would define the cluster 'mycluster', and be loaded automatically by valkey-php. ```ini # In redis.ini @@ -43,59 +43,59 @@ redis.clusters.auth = "mycluster=password" Then, this cluster can be loaded by doing the following ```php -$obj_cluster = new RedisCluster('mycluster'); +$obj_cluster = new ValkeyCluster('mycluster'); ``` ## Connection process -On construction, the RedisCluster class will iterate over the provided seed nodes until it can attain a connection to the cluster and run CLUSTER SLOTS to map every node in the cluster locally. Once the keyspace is mapped, RedisCluster will only connect to nodes when it needs to (e.g. you're getting a key that we believe is on that node.) +On construction, the ValkeyCluster class will iterate over the provided seed nodes until it can attain a connection to the cluster and run CLUSTER SLOTS to map every node in the cluster locally. Once the keyspace is mapped, ValkeyCluster will only connect to nodes when it needs to (e.g. you're getting a key that we believe is on that node.) ## Slot caching -Each time the `RedisCluster` class is constructed from scratch, phpredis needs to execute a `CLUSTER SLOTS` command to map the keyspace. Although this isn't an expensive command, it does require a round trip for each newly created object, which is inefficient. Starting from PhpRedis 5.0.0 these slots can be cached by setting `redis.clusters.cache_slots = 1` in `php.ini`. +Each time the `ValkeyCluster` class is constructed from scratch, valkey-php needs to execute a `CLUSTER SLOTS` command to map the keyspace. Although this isn't an expensive command, it does require a round trip for each newly created object, which is inefficient. Starting from PhpValkey 5.0.0 these slots can be cached by setting `redis.clusters.cache_slots = 1` in `php.ini`. ## Timeouts -Because Redis cluster is intended to provide high availability, timeouts do not work in the same way they do in normal socket communication. It's fully possible to have a timeout or even exception on a given socket (say in the case that a master node has failed), and continue to serve the request if and when a slave can be promoted as the new master. +Because Valkey cluster is intended to provide high availability, timeouts do not work in the same way they do in normal socket communication. It's fully possible to have a timeout or even exception on a given socket (say in the case that a master node has failed), and continue to serve the request if and when a slave can be promoted as the new master. -The way RedisCluster handles user specified timeout values is that every time a command is sent to the cluster, we record the time at the start of the request and then again every time we have to re-issue the command to a different node (either because Redis cluster responded with MOVED/ASK or because we failed to communicate with a given node). Once we detect having been in the command loop for longer than our specified timeout, an error is raised. +The way ValkeyCluster handles user specified timeout values is that every time a command is sent to the cluster, we record the time at the start of the request and then again every time we have to re-issue the command to a different node (either because Valkey cluster responded with MOVED/ASK or because we failed to communicate with a given node). Once we detect having been in the command loop for longer than our specified timeout, an error is raised. ## Keyspace map -As previously described, RedisCluster makes an initial mapping of every master (and any slaves) on construction, which it uses to determine which nodes to direct a given command. However, one of the core functionalities of Redis cluster is that this keyspace can change while the cluster is running. +As previously described, ValkeyCluster makes an initial mapping of every master (and any slaves) on construction, which it uses to determine which nodes to direct a given command. However, one of the core functionalities of Valkey cluster is that this keyspace can change while the cluster is running. -Because of this, the RedisCluster class will update its keyspace mapping whenever it receives a MOVED error when requesting data. In the case that we receive ASK redirection, it follows the Redis specification and requests the key from the ASK node, prefixed with an ASKING command. +Because of this, the ValkeyCluster class will update its keyspace mapping whenever it receives a MOVED error when requesting data. In the case that we receive ASK redirection, it follows the Valkey specification and requests the key from the ASK node, prefixed with an ASKING command. ## Automatic slave failover / distribution -By default, RedisCluster will only ever send commands to master nodes, but can be configured differently for readonly commands if requested. +By default, ValkeyCluster will only ever send commands to master nodes, but can be configured differently for readonly commands if requested. ```php // The default option, only send commands to master nodes -$obj_cluster->setOption(RedisCluster::OPT_SLAVE_FAILOVER, RedisCluster::FAILOVER_NONE); +$obj_cluster->setOption(ValkeyCluster::OPT_SLAVE_FAILOVER, ValkeyCluster::FAILOVER_NONE); // In the event we can't reach a master, and it has slaves, failover for read commands -$obj_cluster->setOption(RedisCluster::OPT_SLAVE_FAILOVER, RedisCluster::FAILOVER_ERROR); +$obj_cluster->setOption(ValkeyCluster::OPT_SLAVE_FAILOVER, ValkeyCluster::FAILOVER_ERROR); // Always distribute readonly commands between masters and slaves, at random $obj_cluster->setOption( - RedisCluster::OPT_SLAVE_FAILOVER, RedisCluster::FAILOVER_DISTRIBUTE + ValkeyCluster::OPT_SLAVE_FAILOVER, ValkeyCluster::FAILOVER_DISTRIBUTE ); // Always distribute readonly commands to the slaves, at random $obj_cluster->setOption( - RedisCluster::OPT_SLAVE_FAILOVER, RedisCluster::FAILOVER_DISTRIBUTE_SLAVES + ValkeyCluster::OPT_SLAVE_FAILOVER, ValkeyCluster::FAILOVER_DISTRIBUTE_SLAVES ); ``` ## Main command loop -With the exception of commands that are directed to a specific node, each command executed via RedisCluster is processed through a command loop, where we make the request, handle any MOVED or ASK redirection, and repeat if necessary. This continues until one of the following conditions is met: +With the exception of commands that are directed to a specific node, each command executed via ValkeyCluster is processed through a command loop, where we make the request, handle any MOVED or ASK redirection, and repeat if necessary. This continues until one of the following conditions is met: -1. We fail to communicate with *any* node that we are aware of, in which case a `RedisClusterException` is raised. +1. We fail to communicate with *any* node that we are aware of, in which case a `ValkeyClusterException` is raised. 2. We have been bounced around longer than the timeout which was set on construction. -3. Redis cluster returns to us a `CLUSTERDOWN` error, in which case a `RedisClusterException` is raised. +3. Valkey cluster returns to us a `CLUSTERDOWN` error, in which case a `ValkeyClusterException` is raised. 4. We receive a valid response, in which case the data is returned to the caller. ## Transactions -The RedisCluster class fully supports MULTI ... EXEC transactions, including commands such as MGET and MSET which operate on multiple keys. There are considerations that must be taken into account here however. +The ValkeyCluster class fully supports MULTI ... EXEC transactions, including commands such as MGET and MSET which operate on multiple keys. There are considerations that must be taken into account here however. -When you call `RedisCluster->multi()`, the cluster is put into a MULTI state, but the MULTI command is not delivered to any nodes until a key is requested on that node. In addition, calls to EXEC will always return an array (even in the event that a transaction to a given node failed), as the commands can be going to any number of nodes depending on what is called. +When you call `ValkeyCluster->multi()`, the cluster is put into a MULTI state, but the MULTI command is not delivered to any nodes until a key is requested on that node. In addition, calls to EXEC will always return an array (even in the event that a transaction to a given node failed), as the commands can be going to any number of nodes depending on what is called. Consider the following example: @@ -117,15 +117,15 @@ print_r($obj_cluster->exec()); ``` ## Pipelining -The RedisCluster class does not support pipelining as there is no way to detect whether the keys still live where our map indicates that they do and would therefore be inherently unsafe. It would be possible to implement this support as an option if there is demand for such a feature. +The ValkeyCluster class does not support pipelining as there is no way to detect whether the keys still live where our map indicates that they do and would therefore be inherently unsafe. It would be possible to implement this support as an option if there is demand for such a feature. ## Multiple key commands -Redis cluster does allow commands that operate on multiple keys, but only if all of those keys hash to the same slot. Note that it is not enough that the keys are all on the same node, but must actually hash to the exact same hash slot. +Valkey cluster does allow commands that operate on multiple keys, but only if all of those keys hash to the same slot. Note that it is not enough that the keys are all on the same node, but must actually hash to the exact same hash slot. -For all of these multiple key commands (with the exception of MGET and MSET), the RedisCluster class will verify each key maps to the same hash slot and raise a "CROSSSLOT" warning, returning false if they don't. +For all of these multiple key commands (with the exception of MGET and MSET), the ValkeyCluster class will verify each key maps to the same hash slot and raise a "CROSSSLOT" warning, returning false if they don't. ### MGET, MSET, DEL, and UNLINK -RedisCluster has specialized processing for MGET, MSET, DEL, and UNLINK which allows you to send any number of keys (hashing to whichever slots) without having to consider where they live. The way this works, is that the RedisCluster class will split the command as it iterates through keys, delivering a subset of commands per each key's slot. +ValkeyCluster has specialized processing for MGET, MSET, DEL, and UNLINK which allows you to send any number of keys (hashing to whichever slots) without having to consider where they live. The way this works, is that the ValkeyCluster class will split the command as it iterates through keys, delivering a subset of commands per each key's slot. *Note: If you send keys that hash to more than one slot, these commands are no longer atomic.* @@ -149,7 +149,7 @@ foreach ($obj_cluster->_masters() as $arr_master) { } ``` -In the case of all commands which need to be directed at a node, the calling convention is identical to the Redis call, except that they require an additional (first) argument in order to deliver the command. Following is a list of each of these commands: +In the case of all commands which need to be directed at a node, the calling convention is identical to the Valkey call, except that they require an additional (first) argument in order to deliver the command. Following is a list of each of these commands: 1. ACL 1. BGREWRITEAOF @@ -175,9 +175,9 @@ In the case of all commands which need to be directed at a node, the calling con 1. TIME ## Session Handler -You can use the cluster functionality of phpredis to store PHP session information in a Redis cluster as you can with a non cluster-enabled Redis instance. +You can use the cluster functionality of valkey-php to store PHP session information in a Valkey cluster as you can with a non cluster-enabled Valkey instance. -To do this, you must configure your `session.save_handler` and `session.save_path` INI variables to give phpredis enough information to communicate with the cluster. +To do this, you must configure your `session.save_handler` and `session.save_path` INI variables to give valkey-php enough information to communicate with the cluster. ```ini session.save_handler = rediscluster @@ -185,18 +185,18 @@ session.save_path = "seed[]=host1:port1&seed[]=host2:port2&seed[]=hostN:portN&ti ``` ### session.session_handler -Set this variable to "rediscluster" to inform phpredis that this is a cluster instance. +Set this variable to "rediscluster" to inform valkey-php that this is a cluster instance. ### session.save_path The save path for cluster based session storage takes the form of a PHP GET request, and requires that you specify at least one `seed` node. Other options you can specify are as follows: -* _timeout (double)_: The amount of time phpredis will wait when connecting or writing to the cluster. -* _read\_timeout (double)_: The amount of time phpredis will wait for a result from the cluster. -* _persistent_: Tells phpredis whether persistent connections should be used. -* _failover (string)_: How phpredis should distribute session reads between master and slave nodes. - * _none_ : phpredis will only communicate with master nodes - * _error_: phpredis will communicate with master nodes unless one fails, in which case an attempt will be made to read session information from a slave. - * _distribute_: phpredis will randomly distribute session reads between masters and any attached slaves (load balancing). +* _timeout (double)_: The amount of time valkey-php will wait when connecting or writing to the cluster. +* _read\_timeout (double)_: The amount of time valkey-php will wait for a result from the cluster. +* _persistent_: Tells valkey-php whether persistent connections should be used. +* _failover (string)_: How valkey-php should distribute session reads between master and slave nodes. + * _none_ : valkey-php will only communicate with master nodes + * _error_: valkey-php will communicate with master nodes unless one fails, in which case an attempt will be made to read session information from a slave. + * _distribute_: valkey-php will randomly distribute session reads between masters and any attached slaves (load balancing). * _auth (string, empty by default)_: The password used to authenticate with the server prior to sending commands. * _stream (array)_: ssl/tls stream context options. @@ -207,7 +207,7 @@ To enable, set the following INI variable: ```ini redis.session.early_refresh = 1 ``` -Note: This is disabled by default since it may significantly reduce the session lifetime for long-running scripts. Redis server version 6.2+ required. +Note: This is disabled by default since it may significantly reduce the session lifetime for long-running scripts. Valkey server version 6.2+ required. ### Session compression diff --git a/docs/content/README.md b/docs/content/README.md index 30f5fb1ae7..fd6734a4d9 100644 --- a/docs/content/README.md +++ b/docs/content/README.md @@ -6,53 +6,53 @@ ### Installation -For everything you should need to install PhpRedis on your system, +For everything you should need to install PhpValkey on your system, see the [INSTALL.md](./INSTALL.md) page. ### PHP Session handler -phpredis can be used to store PHP sessions. To do this, configure `session.save_handler` and `session.save_path` in your php.ini to tell phpredis where to store the sessions. +valkey-php can be used to store PHP sessions. To do this, configure `session.save_handler` and `session.save_path` in your php.ini to tell valkey-php where to store the sessions. `session.save_path` can have a simple `host:port` format too, but you need to provide the `tcp://` scheme if you want to use the parameters. The following parameters are available: - __weight__ (integer): the weight of a host is used in comparison with the others in order to customize the session distribution on several hosts. If host A has twice the weight of host B, it will get twice the amount of sessions. In the example, *host1* stores 20% of all the sessions (1/(1+2+2)) while *host2* and *host3* each store 40% (2/(1+2+2)). The target host is determined once and for all at the start of the session, and doesn't change. The default weight is 1. - __timeout__ (float): the connection timeout to a redis host, expressed in seconds. If the host is unreachable in that amount of time, the session storage will be unavailable for the client. The default timeout is very high (86400 seconds). - __persistent__ (integer, should be 1 or 0): defines if a persistent connection should be used. -- __prefix__ (string, defaults to "PHPREDIS_SESSION:"): used as a prefix to the Redis key in which the session is stored. The key is composed of the prefix followed by the session ID. +- __prefix__ (string, defaults to "PHPVALKEY_SESSION:"): used as a prefix to the Valkey key in which the session is stored. The key is composed of the prefix followed by the session ID. - __auth__ (string, or an array with one or two elements): used to authenticate with the server prior to sending commands. - __database__ (integer): selects a different database. Sessions have a lifetime expressed in seconds and stored in the INI variable "session.gc_maxlifetime". You can change it with [`ini_set()`](http://php.net/ini_set). -The session handler requires a version of Redis supporting `EX` and `NX` options of `SET` command (at least 2.6.12). -phpredis can also connect to a unix domain socket: `session.save_path = "unix:///var/run/redis/redis.sock?persistent=1&weight=1&database=0"`. +The session handler requires a version of Valkey supporting `EX` and `NX` options of `SET` command (at least 2.6.12). +valkey-php can also connect to a unix domain socket: `session.save_path = "unix:///var/run/redis/redis.sock?persistent=1&weight=1&database=0"`. #### Examples -Multiple Redis servers: +Multiple Valkey servers: ```ini session.save_handler = redis session.save_path = "tcp://host1:6379?weight=1, tcp://host2:6379?weight=2&timeout=2.5, tcp://host3:6379?weight=2&read_timeout=2.5" ``` -Login to Redis using username and password: +Login to Valkey using username and password: ```ini session.save_handler = redis session.save_path = "tcp://127.0.0.1:6379?auth[]=user&auth[]=password" ``` -Login to Redis using username, password, and set prefix: +Login to Valkey using username, password, and set prefix: ```ini session.save_handler = redis -session.save_path = "tcp://127.0.0.1:6379?auth[]=user&auth[]=password&prefix=user_PHPREDIS_SESSION:" +session.save_path = "tcp://127.0.0.1:6379?auth[]=user&auth[]=password&prefix=user_PHPVALKEY_SESSION:" ``` #### Session locking -__Support__: Locking feature is currently only supported for Redis setup with single master instance (e.g. classic master/slave Sentinel environment). -So locking may not work properly in RedisArray or RedisCluster environments. +__Support__: Locking feature is currently only supported for Valkey setup with single master instance (e.g. classic master/slave Sentinel environment). +So locking may not work properly in ValkeyArray or ValkeyCluster environments. Following INI variables can be used to configure session locking: @@ -80,29 +80,29 @@ redis.session.compression_level = 3 ### Running the unit tests -phpredis uses a small custom unit test suite for testing functionality of the various classes. To run tests, simply do the following: +valkey-php uses a small custom unit test suite for testing functionality of the various classes. To run tests, simply do the following: ```bash -## Run tests for Redis class (note this is the default) -php tests/TestRedis.php --class Redis +## Run tests for Valkey class (note this is the default) +php tests/TestValkey.php --class Valkey -## Run tests for RedisArray class +## Run tests for ValkeyArray class tests/mkring.sh start -php tests/TestRedis.php --class RedisArray +php tests/TestValkey.php --class ValkeyArray tests/mkring.sh stop -## Run tests for the RedisCluster class +## Run tests for the ValkeyCluster class tests/make-cluster.sh start -php tests/TestRedis.php --class RedisCluster +php tests/TestValkey.php --class ValkeyCluster tests/make-cluster.sh stop -## Run tests for RedisSentinel class -php tests/TestRedis.php --class RedisSentinel +## Run tests for ValkeySentinel class +php tests/TestValkey.php --class ValkeySentinel ``` Note that it is possible to run only tests which match a substring of the test itself by passing the additional argument '--test ' when invoking. ```bash ## Just run the 'echo' test -php tests/TestRedis.php --class Redis --test echo +php tests/TestValkey.php --class Valkey --test echo ``` diff --git a/docs/content/bitmaps.md b/docs/content/bitmaps.md index e69de29bb2..34c3bd8583 100644 --- a/docs/content/bitmaps.md +++ b/docs/content/bitmaps.md @@ -0,0 +1,220 @@ +# Valkey PHP - Bitmaps + +|Command |Description |Supported |Tested |Class/Trait |Method | +|--- |--- |:-: |:-: |--- |--- | +|[bitCount](#bitCount) |Count set bits in a string |:white\_check\_mark: |:white\_check\_mark: |Bitmaps |bitCount | +|[bitField](#bitField) |Perform arbitrary bitfield integer operations on strings |:x: |:x: |Bitmaps |bitField | +|[bitFieldReadOnly](#bitFieldReadOnly) |Perform arbitrary read-only bitfield integer operations on strings |:x: |:x: |Bitmaps |bitFieldReadOnly | +|[bitOp](#bitOp) |Perform bitwise operations between strings |:white\_check\_mark: |:white\_check\_mark: |Bitmaps |bitOp | +|[bitPos](#bitPos) |Return the position of the first bit set to 1 or 0 in a string. |:x: |:x: |Bitmaps |bitPos | +|[getBit](#getBit) |Returns the bit value at offset in the string value stored at key |:white\_check\_mark: |:white\_check\_mark: |Bitmaps |getBit | +|[setBit](#setBit) |Sets or clears the bit at offset in the string value stored at key |:white\_check\_mark: |:white\_check\_mark: |Bitmaps |setBit | + +## Usage + +```php +$valkey = new Valkey(); +$valkey->bitCount('key'); +$valkey->bitField('key', 'INCRBY, 'i5', 100, 1, 'GET', 'u4', 0); +$valkey->bitFieldReadOnly('key', 'INCRBY, 'i5', 100, 1, 'GET', 'u4', 0); +$valkey->bitOp('and', 'testBitOpAnd', 'testBit1', 'testBit2'); +$valkey->bitpos('key', 0); +$valkey->getBit('key', 5); +$valkey->setBit('key', 8, 1); +``` + +## bitCount + +_**Description**_: Count set bits in a string. + +##### *Prototype* + +```php +public function bitCount(string $key) : int { + return $this->valkey->bitCount($key); +} +``` + +##### *Parameters* + +- *key*: String. The key append to. + +##### *Return value* + +*int*: Total of bits set in the string. + +##### *Example* + +```php +$valkey->set('key', 'a'); // 0110 0001 in Binary or 97 in decimal +$valkey->bitCount('key'); // 3 +``` + +## bitField + +_**Description**_: Perform arbitrary bitfield integer operations on strings + +##### *Prototype* + +```php +public function bitField(string $key, ...$params): array { + return []; +} +``` + +##### *Parameters* + +- *key*: String. The key. + +##### *Return value* + +*array*: each entry being the corresponding result of the sub-command given at the same position. + +##### *Example* + +```php +$valkey->bitField('key', 'INCRBY, 'i5', 100, 1, 'GET', 'u4', 0); +``` + +## bitOp + +_**Description**_: Perform bitwise operations between strings. + +##### *Prototype* + +```php +public function bitOp(string $operation, string $returnKey, ...$keys): int { + return $this->valkey->bitOp($key); +} +``` + +##### *Parameters* + +- *operation*: String. Bitwise operation to perform: "AND", "OR", "NOT", "XOR" +- *returnKey*: String. The key where the result will be saved. +- *keys*: String(s). The key(s) part of he operation. + +##### *Return value* + +*int*: The size of the string stored in the destination key. + +##### *Example* + +```php +$valkey->bitOp('not', 'testBitOpNot', 'testBit'); + +$valkey->set('testBit1', 0); +$valkey->set('testBit2', 1); +$valkey->bitOp('and', 'testBitOpAnd', 'testBit1', 'testBit2'); +$valkey->get('testBitOpAnd'); // 0 since only the two bits that are common + // between 0 and 1 will match +``` + +## bitPos + +_**Description**_: Return the position of the first bit set to 1 or 0 in a string. + +##### *Prototype* + +```php +public function bitPos(string $key, int $bit, int $start = 0, int $end, string $type): int { + if ($type != 'BYTE' || $type != 'BIT') { + return -1; + } + return $this->valkey->bitPos($key, $bit, $start, $end, $type); +} +``` + +##### *Parameters* + +- *key*: String. The Bitmap key. +- *value*: int. 0 or 1, the value of the bit to look for. +- *start*: int. 0 or 1, the value of the bit to look for. + +##### *Return value* + +*int*: The size of the string stored in the destination key. + +##### *Example* + +```php +$valkey->set('key', 'A'); // 0100 0001 + // ^ + // | +$valkey->bitPos('key', 0); // 0 found at the first position + +$valkey->get('key'); // 0100 0001 + // ^ + // | +$valkey->bitPos('key', 1); // 1 found on the second position (zero based) +``` + +## getBit + +_**Description**_: Returns the bit value at offset in the string value stored at key. + +##### *Prototype* + +```php +public function getBit(string $key, int $offset) : int { + return $this->valkey->getBit($key, $offset); +} +``` + +##### *Parameters* + +- *key*: String. The Bitmap key. +- *offset*: String. The bit position within the string. + +##### *Return value* + +*int*: 0 or 1 + +##### *Example* + +```php +$valkey->set('key', 'A'); // 0100 0001 + // ^ + // | +$valkey->getBit('key', 3); // 0 is the 4th element (zero based) + +$valkey->get('key'); // 0100 0001 + // ^ + // | +$valkey->getBit('key', 7); // 1 is the 8th element (zero based) +``` + +## setBit + +_**Description**_: Sets or clears the bit at offset in the string value stored at key. + +##### *Prototype* + +```php +public function setBit(string $key, int $offset, int $value): int { + return $this->valkey->setBit($key, $offset, $value); +} +``` + +##### *Parameters* + +- *key*: String. The Bitmap key. +- *offset*: int. The bit position within the string. +- *value*: int. 0 or 1, the value of the bit to set. + +##### *Return value* + +*int*: 0 or 1, the value of the bit before it was set. + +##### *Example* + +```php +$valkey->setBit('key', 1, 1); // 01 +$valkey->setBit('key', 7, 1); // 0100 0001 +$valkey->get('key'); // A => 0100 0001 + +$valkey->set('key', "*"); // ord("*") = 42 = 0x2f = "0010 1010" +$valkey->setBit('key', 5, 1); // returns 0 +$valkey->setBit('key', 7, 1); // returns 0 +$valkey->get('key'); // chr(0x2f) = "/" = b("0010 1111") +``` diff --git a/docs/content/connection.md b/docs/content/connection.md index e69de29bb2..01a9362aa4 100644 --- a/docs/content/connection.md +++ b/docs/content/connection.md @@ -0,0 +1,335 @@ +# Valkey PHP - Connections management + +|Command |Description |Supported |Tested |Class/Trait |Method | +|--- |--- |:-: |:-: |--- |--- | +|[auth](#auth) |Authenticate the connectionto the server |:white\_check\_mark: |:white\_check\_mark: |Connections |auth | +|[connect](#connect) |Connect to a server |:white\_check\_mark: |:white\_check\_mark: |Connections |connect | +|[close](#close) |Close the connection |:white\_check\_mark: |:white\_check\_mark: |Connections |close | +|[echo](#echo) |Echo the given string |:white\_check\_mark: |:white\_check\_mark: |Connections |echo | +|[getOption](#getOption) |Get client option |:white\_check\_mark: |:white\_check\_mark: |Connections |getOption | +|[open](#open) |Connect to a server |:white\_check\_mark: |:white\_check\_mark: |Connections |open | +|[pconnect](#pconnect) |Connect to a server (persistent) |:white\_check\_mark: |:white\_check\_mark: |Connections |pconnect | +|[ping](#ping) |Ping the server |:white\_check\_mark: |:white\_check\_mark: |Connections |ping | +|[popen](#popen) |Connect to a server (persistent) |:white\_check\_mark: |:white\_check\_mark: |Connections |popen | +|[select](#select) |Change the selected database for the current connection |:white\_check\_mark: |:white\_check\_mark: |Connections |select | +|[setOption](#setOption) |Set client option |:white\_check\_mark: |:white\_check\_mark: |Connections |setOption | +|[swapdb](#swapdb) |Swaps two Valkey databases |:white\_check\_mark: |:white\_check\_mark: |Connections |swapdb | + +## Usage + +```php +$valkey = new Valkey(); +$valkey->connect('127.0.0.1', 6379); +$valkey->open('127.0.0.1', 6379); +$valkey->pconnect('127.0.0.1', 6379); +$valkey->popen('127.0.0.1', 6379); +$valkey->auth('secret'); +$valkey->select(1); +$valkey->swapdb(0, 1); +$valkey->close(); +$valkey->setOption(\Valkey::OPT_PREFIX, 'redis:'); +$valkey->getOption(\Valkey::OPT_PREFIX) +$valkey->ping('pong'); +$valkey->echo('redis'); +``` + +## auth + +_**Description**_: Authenticate the connection using a password or a username and password. +*Warning*: The password is sent in plain-text over the network. + +##### *Prototype* + +```php +public function auth(string $password | array $credentials = []) : bool { + return $this->valkey->auth($password); +} +``` + +##### *Parameters* +*MIXED*: password + +##### *Return value* +*BOOL*: `TRUE` if the connection is authenticated, `FALSE` otherwise. + +*Note*: In order to authenticate with a username and password you need Valkey >= 6.0. + +##### *Example* + +```php +$valkey = new Valkey(); +$valkey->connect('127.0.0.1', 6379); + +/* Authenticate with the password 'foobared' */ +$valkey->auth('foobared'); + +/* Authenticate with the username 'valkey-php', and password 'haxx00r' */ +$valkey->auth(['valkey-php', 'haxx00r']); + +/* Authenticate with the password 'foobared' */ +$valkey->auth(['foobared']); + +/* You can also use an associative array specifying user and pass */ +$valkey->auth(['user' => 'valkey-php', 'pass' => 'valkey-php']); +$valkey->auth(['pass' => 'valkey-php']); +``` + +### connect, open +----- +_**Description**_: Connects to a Valkey instance. + +##### *Prototype* + +```php +public function connect( + string $host = '127.0.0.1', + int $port = 6379, + float $timeout = 0.0, + $reserved = null, + int $retry_interval = 0, + float $read_timeout = 0, + array $others = [] +) : bool +``` + +##### *Parameters* + +*host*: string. can be a host, or the path to a unix domain socket. Starting from version 5.0.0 it is possible to specify schema +*port*: int, optional +*timeout*: float, value in seconds (optional, default is 0 meaning it will use default_socket_timeout) +*reserved*: should be '' if retry_interval is specified +*retry_interval*: int, value in milliseconds (optional) +*read_timeout*: float, value in seconds (optional, default is 0 meaning it will use default_socket_timeout) +*others*: array, with PhpValkey >= 5.3.0, it allows setting _auth_ and [_stream_](https://www.php.net/manual/en/context.ssl.php) configuration. + +##### *Return value* + +*BOOL*: `TRUE` on success, `FALSE` on error. + +##### *Example* + +```php +$valkey = new Valkey(); +$valkey->connect('127.0.0.1', 6379); +$valkey->connect('127.0.0.1'); // port 6379 by default +$valkey->connect('tls://127.0.0.1', 6379); // enable transport level security. +$valkey->connect('tls://127.0.0.1'); // enable transport level security, port 6379 by default. +$valkey->connect('127.0.0.1', 6379, 2.5); // 2.5 sec timeout. +$valkey->connect('/tmp/redis.sock'); // unix domain socket. +$valkey->connect('127.0.0.1', 6379, 1, '', 100); // 1 sec timeout, 100ms delay between reconnection attempts. +$valkey->connect('/tmp/redis.sock', 0, 1.5, NULL, 0, 1.5); // Unix socket with 1.5s timeouts (connect and read) + +/* With PhpValkey >= 5.3.0 you can specify authentication and stream information on connect */ +$valkey->connect('127.0.0.1', 6379, 1, '', 0, 0, ['auth' => ['valkey-php', 'valkey-php']]); +``` + +**Note:** `open` is an alias for `connect` and will be removed in future versions of valkey-php. + +## close + +----- + +_**Description**_: Disconnects from the Valkey instance. + +*Note*: Closing a persistent connection requires PhpValkey >= 4.2.0. + +##### *Prototype* + +```php +public function close() : bool { + return $this->valkey->close(); +} +``` + +##### *Parameters* + +None. + +##### *Return value* +*BOOL*: `TRUE` on success, `FALSE` on failure. + +##### *Example* + +```php +$valkey = new Valkey(); +$valkey->connect('127.0.0.1', 6379); +$valkey->close(); +``` + +### pconnect, popen + +----- + +_**Description**_: Connects to a Valkey instance or reuse a connection already established with `pconnect`/`popen`. + +The connection will not be closed on end of request until the php process ends. +So be prepared for too many open FD's errors (specially on redis server side) when using persistent +connections on many servers connecting to one redis server. + +Also more than one persistent connection can be made identified by either host + port + timeout +or host + persistent_id or unix socket + timeout. + +Starting from version 4.2.1, it became possible to use connection pooling by setting INI variable `redis.pconnect.pooling_enabled` to 1. + +This feature is not available in threaded versions. `pconnect` and `popen` then working like their non +persistent equivalents. + +##### *Parameters* + +*host*: string. can be a host, or the path to a unix domain socket. Starting from version 5.0.0 it is possible to specify schema +*port*: int, optional +*timeout*: float, value in seconds (optional, default is 0 meaning it will use default_socket_timeout) +*persistent_id*: string. identity for the requested persistent connection +*retry_interval*: int, value in milliseconds (optional) +*read_timeout*: float, value in seconds (optional, default is 0 meaning it will use default_socket_timeout) + +##### *Return value* + +*BOOL*: `TRUE` on success, `FALSE` on error. + +##### *Example* + +```php +$valkey->pconnect('127.0.0.1', 6379); +$valkey->pconnect('127.0.0.1'); // port 6379 by default - same connection like before. +$valkey->pconnect('tls://127.0.0.1', 6379); // enable transport level security. +$valkey->pconnect('tls://127.0.0.1'); // enable transport level security, port 6379 by default. +$valkey->pconnect('127.0.0.1', 6379, 2.5); // 2.5 sec timeout and would be another connection than the two before. +$valkey->pconnect('127.0.0.1', 6379, 2.5, 'x'); // x is sent as persistent_id and would be another connection than the three before. +$valkey->pconnect('/tmp/redis.sock'); // unix domain socket - would be another connection than the four before. +``` + +**Note:** `popen` is an alias for `pconnect` and will be removed in future versions of valkey-php. + +### select + +----- + +_**Description**_: Change the selected database for the current connection. + +##### *Parameters* +*INTEGER*: dbindex, the database number to switch to. + +##### *Return value* +`TRUE` in case of success, `FALSE` in case of failure. +##### *Example* +See method for example: [move](#move) + +### swapdb + +----- + +_**Description**_: Swap one Valkey database with another atomically + +##### *Parameters* +*INTEGER*: db1 +*INTEGER*: db2 + +##### *Return value* +`TRUE` on success and `FALSE` on failure. + +*Note*: Requires Valkey >= 4.0.0 + +##### *Example* +```php +$valkey->swapdb(0, 1); /* Swaps DB 0 with DB 1 atomically */ +``` + +### setOption + +----- + +_**Description**_: Set client option. + +##### *Parameters* +*parameter name* +*parameter value* + +##### *Return value* +*BOOL*: `TRUE` on success, `FALSE` on error. + +##### *Example* + +```php +$valkey->setOption(Valkey::OPT_SERIALIZER, Valkey::SERIALIZER_NONE); // Don't serialize data +$valkey->setOption(Valkey::OPT_SERIALIZER, Valkey::SERIALIZER_PHP); // Use built-in serialize/unserialize +$valkey->setOption(Valkey::OPT_SERIALIZER, Valkey::SERIALIZER_IGBINARY); // Use igBinary serialize/unserialize +$valkey->setOption(Valkey::OPT_SERIALIZER, Valkey::SERIALIZER_MSGPACK); // Use msgpack serialize/unserialize +$valkey->setOption(Valkey::OPT_SERIALIZER, Valkey::SERIALIZER_JSON); // Use JSON to serialize/unserialize + +$valkey->setOption(Valkey::OPT_PREFIX, 'myAppName:'); // use custom prefix on all keys + +/* Options for the SCAN family of commands, indicating whether to abstract + empty results from the user. If set to SCAN_NORETRY (the default), valkey-php + will just issue one SCAN command at a time, sometimes returning an empty + array of results. If set to SCAN_RETRY, valkey-php will retry the scan command + until keys come back OR Valkey returns an iterator of zero +*/ +$valkey->setOption(Valkey::OPT_SCAN, Valkey::SCAN_NORETRY); +$valkey->setOption(Valkey::OPT_SCAN, Valkey::SCAN_RETRY); + +/* Scan can also be configured to automatically prepend the currently set PhpValkey + prefix to any MATCH pattern. */ +$valkey->setOption(Valkey::OPT_SCAN, Valkey::SCAN_PREFIX); +$valkey->setOption(Valkey::OPT_SCAN, Valkey::SCAN_NOPREFIX); +``` + +### getOption + +----- + +_**Description**_: Get client option. + +##### *Parameters* +*parameter name* + +##### *Return value* +Parameter value. + +##### *Example* + +```php +// return Valkey::SERIALIZER_NONE, Valkey::SERIALIZER_PHP, +// Valkey::SERIALIZER_IGBINARY, Valkey::SERIALIZER_MSGPACK or Valkey::SERIALIZER_JSON +$valkey->getOption(Valkey::OPT_SERIALIZER); +``` + +### ping + +----- + +_**Description**_: Check the current connection status. + +##### *Prototype* +```php +$valkey->ping([string $message]); +``` + +##### *Return value* +*Mixed*: This method returns `TRUE` on success, or the passed string if called with an argument. + +##### *Example* + +```php +/* When called without an argument, PING returns `TRUE` */ +$valkey->ping(); + +/* If passed an argument, that argument is returned. Here 'hello' will be returned */ +$valkey->ping('hello'); +``` + +*Note*: Prior to PhpValkey 5.0.0 this command simply returned the string `+PONG`. + +### echo + +----- + +_**Description**_: Sends a string to Valkey, which replies with the same string + +##### *Parameters* + +*STRING*: The message to send. + +##### *Return value* + +*STRING*: the same message. diff --git a/docs/content/generic.md b/docs/content/generic.md new file mode 100644 index 0000000000..abb216d011 --- /dev/null +++ b/docs/content/generic.md @@ -0,0 +1,28 @@ +## Generic +1. [rawCommand](#rawcommand) - Execute any generic command against the server. + +### rawCommand +----- +_**Description**_: A method to execute any arbitrary command against the a Valkey server + +##### *Parameters* +This method is variadic and takes a dynamic number of arguments of various types (string, long, double), but must be passed at least one argument (the command keyword itself). + +##### *Return value* +The return value can be various types depending on what the server itself returns. No post processing is done to the returned value and must be handled by the client code. + +##### *Example* + +```php +/* Returns: true */ +$valkey->rawCommand("set", "foo", "bar"); + +/* Returns: "bar" */ +$valkey->rawCommand("get", "foo"); + +/* Returns: 3 */ +$valkey->rawCommand("rpush", "mylist", "one", 2, 3.5); + +/* Returns: ["one", "2", "3.5000000000000000"] */ +$valkey->rawCommand("lrange", "mylist", 0, -1); +``` \ No newline at end of file diff --git a/docs/content/geolocation.md b/docs/content/geolocation.md deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/docs/content/geospatial.md b/docs/content/geospatial.md new file mode 100644 index 0000000000..8eff3d76fa --- /dev/null +++ b/docs/content/geospatial.md @@ -0,0 +1,319 @@ +# Valkey PHP - Geospatial Indexes + +|Command |Description |Supported |Tested |Class/Trait |Method | +|--- |--- |:-: |:-: |--- |--- | +|[geoAdd](#geoAdd) |Add one or more geospatial items to the specified key. |:white\_check\_mark: |:white\_check\_mark: |Geospatial |geoAdd | +|[geoDist](#geoDist) |Return the distance between two members in a geospatial set. |:white\_check\_mark: |:white\_check\_mark: |Geospatial |geoDist | +|[geoHash](#geoHash) |Retrieve Geohash strings for one or more elements of a geospatial index. |:white\_check\_mark: |:white\_check\_mark: |Geospatial |geoHash | +|[geoPos](#geoPos) |Return longitude, latitude positions for each requested member. |:white\_check\_mark: |:white\_check\_mark: |Geospatial |geoPos | +|[geoRadius](#geoRadius)|Return members of a set with geospatial information that are within the radius specified by the caller.|:white\_check\_mark: |:white\_check\_mark: |Geospatial |geoRadius | +|[geoRadiusByMember](#geoRadiusByMember)|This method is identical to geoRadius except that instead of passing a longitude and latitude as the "source" you pass an existing member in the geospatial set.|:white\_check\_mark:|:white\_check\_mark:|Geospatial|geoRadiusByMember| + +## Usage + +```php +$valkey = new Valkey(); +$valkey->connect('127.0.0.1', 6379); +$options = ['WITHDIST']; +$valkey->geoAdd('Geospatial', -122.431, 37.773, 'San Francisco'); +$valkey->geoAdd('Geospatial', -73.935242, 40.730610, 'New York'); +$valkey->geoHash('Geospatial', 'San Francisco'); +$valkey->geoPos('Geospatial', 'San Francisco'); +$valkey->geoDist('Geospatial', 'San Francisco', 'New York'); +$valkey->geoRadius("Geospatial", -157.858, 21.306, 300, 'mi', $options) +``` + +### geoAdd +----- + +##### *Prototype* +```php +$valkey->geoAdd($key, $longitude, $latitude, $member [, $longitude, $latitude, $member, ...]); +``` + +_**Description**_: Add one or more geospatial items to the specified key. This function must be called with at least one _longitude, latitude, member_ triplet. + +##### *Return value* +*Integer*: The number of elements added to the geospatial key. + +##### *Example* + +```php +$valkey->del("myplaces"); + +/* Since the key will be new, $result will be 2 */ +$result = $valkey->geoAdd( + "myplaces", + -122.431, 37.773, "San Francisco", + -157.858, 21.315, "Honolulu" +); +``` + +### geoHash +----- + +##### *Prototype* +```php +$valkey->geoHash($key, $member [, $member, $member, ...]); +``` + +_**Description**_: Retrieve Geohash strings for one or more elements of a geospatial index. + +##### *Return value* +*Array*: One or more Valkey Geohash encoded strings. + +##### *Example* +```php +$valkey->geoAdd("hawaii", -157.858, 21.306, "Honolulu", -156.331, 20.798, "Maui"); +$hashes = $valkey->geoHash("hawaii", "Honolulu", "Maui"); +var_dump($hashes); +``` + +##### *Output* +``` +array(2) { + [0]=> + string(11) "87z9pyek3y0" + [1]=> + string(11) "8e8y6d5jps0" +} +``` + +### geoPos +----- + +##### *Prototype* +```php +$valkey->geoPos($key, $member [, $member, $member, ...]); +``` + +_**Description**_: Return longitude, latitude positions for each requested member. + +##### *Return value* +*Array*: One or more longitude/latitude positions + +##### *Example* +```php +$valkey->geoAdd("hawaii", -157.858, 21.306, "Honolulu", -156.331, 20.798, "Maui"); +$positions = $valkey->geoPos("hawaii", "Honolulu", "Maui"); +var_dump($positions); +``` + +##### *Output* +``` +array(2) { + [0]=> + array(2) { + [0]=> + string(22) "-157.85800248384475708" + [1]=> + string(19) "21.3060004581273077" + } + [1]=> + array(2) { + [0]=> + string(22) "-156.33099943399429321" + [1]=> + string(20) "20.79799924753607598" + } +} +``` + +### GeoDist +----- + +##### *Prototype* +```php +$valkey->geoDist($key, $member1, $member2 [, $unit]); +``` + + +_**Description**_: Return the distance between two members in a geospatial set. If units are passed it must be one of the following values: + +* 'm' => Meters +* 'km' => Kilometers +* 'mi' => Miles +* 'ft' => Feet + +##### *Return value* +*Double*: The distance between the two passed members in the units requested (meters by default). + +##### *Example* + +```php +$valkey->geoAdd("hawaii", -157.858, 21.306, "Honolulu", -156.331, 20.798, "Maui"); + +$meters = $valkey->geoDist("hawaii", "Honolulu", "Maui"); +$kilometers = $valkey->geoDist("hawaii", "Honolulu", "Maui", 'km'); +$miles = $valkey->geoDist("hawaii", "Honolulu", "Maui", 'mi'); +$feet = $valkey->geoDist("hawaii", "Honolulu", "Maui", 'ft'); + +echo "Distance between Honolulu and Maui:\n"; +echo " meters : $meters\n"; +echo " kilometers: $kilometers\n"; +echo " miles : $miles\n"; +echo " feet : $feet\n"; + +/* Bad unit */ +$inches = $valkey->geoDist("hawaii", "Honolulu", "Maui", 'in'); +echo "Invalid unit returned:\n"; +var_dump($inches); +``` + +##### *Output* +``` +Distance between Honolulu and Maui: + meters : 168275.204 + kilometers: 168.2752 + miles : 104.5616 + feet : 552084.0028 +Invalid unit returned: +bool(false) +``` + +### geoRadius +----- + +##### *Prototype* +```php +$valkey->geoRadius($key, $longitude, $latitude, $radius, $unit [, Array $options]); +``` + +_**Description**_: Return members of a set with geospatial information that are within the radius specified by the caller. + +##### *Options Array* +The georadius command can be called with various options that control how Valkey returns results. The following table describes the options valkey-php supports. All options are case insensitive. + +| Key | Value | Description +| :--- | :--- | :---- | +| COUNT | integer > 0 | Limit how many results are returned +| | WITHCOORD | Return longitude and latitude of matching members +| | WITHDIST | Return the distance from the center +| | WITHHASH | Return the raw geohash-encoded score +| | ASC | Sort results in ascending order +| | DESC | Sort results in descending order +| STORE | _key_ | Store results in _key_ +| STOREDIST | _key_ | Store the results as distances in _key_ + + *Note*: It doesn't make sense to pass both `ASC` and `DESC` options but if both are passed the last one passed will be used. + *Note*: When using `STORE[DIST]` in Valkey Cluster, the store key must has to the same slot as the query key or you will get a `CROSSLOT` error. + +##### *Return value* +*Mixed*: When no `STORE` option is passed, this function returns an array of results. If it is passed this function returns the number of stored entries. + +##### *Example* + +```php +/* Add some cities */ +$valkey->geoAdd("hawaii", -157.858, 21.306, "Honolulu", -156.331, 20.798, "Maui"); + +echo "Within 300 miles of Honolulu:\n"; +var_dump($valkey->geoRadius("hawaii", -157.858, 21.306, 300, 'mi')); + +echo "\nWithin 300 miles of Honolulu with distances:\n"; +$options = ['WITHDIST']; +var_dump($valkey->geoRadius("hawaii", -157.858, 21.306, 300, 'mi', $options)); + +echo "\nFirst result within 300 miles of Honolulu with distances:\n"; +$options['count'] = 1; +var_dump($valkey->geoRadius("hawaii", -157.858, 21.306, 300, 'mi', $options)); + +echo "\nFirst result within 300 miles of Honolulu with distances in descending sort order:\n"; +$options[] = 'DESC'; +var_dump($valkey->geoRadius("hawaii", -157.858, 21.306, 300, 'mi', $options)); +``` + +##### *Output* +``` +Within 300 miles of Honolulu: +array(2) { + [0]=> + string(8) "Honolulu" + [1]=> + string(4) "Maui" +} + +Within 300 miles of Honolulu with distances: +array(2) { + [0]=> + array(2) { + [0]=> + string(8) "Honolulu" + [1]=> + string(6) "0.0002" + } + [1]=> + array(2) { + [0]=> + string(4) "Maui" + [1]=> + string(8) "104.5615" + } +} + +First result within 300 miles of Honolulu with distances: +array(1) { + [0]=> + array(2) { + [0]=> + string(8) "Honolulu" + [1]=> + string(6) "0.0002" + } +} + +First result within 300 miles of Honolulu with distances in descending sort order: +array(1) { + [0]=> + array(2) { + [0]=> + string(4) "Maui" + [1]=> + string(8) "104.5615" + } +} +``` + +### geoRadiusByMember + +##### *Prototype* +```php +$valkey->geoRadiusByMember($key, $member, $radius, $units [, Array $options]); +``` + +_**Description**_: This method is identical to [geoRadius](#georadius) except that instead of passing a longitude and latitude as the "source" you pass an existing member in the geospatial set. + +##### *Options Array* +See [geoRadius](#georadius) command for options array. + +##### *Return value* +*Array*: The zero or more entries that are close enough to the member given the distance and radius specified. + +##### *Example* + +```php +$valkey->geoAdd("hawaii", -157.858, 21.306, "Honolulu", -156.331, 20.798, "Maui"); + +echo "Within 300 miles of Honolulu:\n"; +var_dump($valkey->geoRadiusByMember("hawaii", "Honolulu", 300, 'mi')); + +echo "\nFirst match within 300 miles of Honolulu:\n"; +var_dump($valkey->geoRadiusByMember("hawaii", "Honolulu", 300, 'mi', ['count' => 1])); +``` + +##### *Output* +``` +Within 300 miles of Honolulu: +array(2) { + [0]=> + string(8) "Honolulu" + [1]=> + string(4) "Maui" +} + +First match within 300 miles of Honolulu: +array(1) { + [0]=> + string(8) "Honolulu" +} +``` diff --git a/docs/content/hashes.md b/docs/content/hashes.md index e69de29bb2..dc592be154 100644 --- a/docs/content/hashes.md +++ b/docs/content/hashes.md @@ -0,0 +1,331 @@ +# Valkey PHP - Hashes + +|Command |Description |Supported |Tested |Class/Trait |Method | +|--- |--- |:-: |:-: |--- |--- | +|[hDel](#hDel) |Delete one or more hash fields |:white\_check\_mark: |:white\_check\_mark: |Hashes |hDel | +|[hExists](#hExists) |Determine if a hash field exists |:white\_check\_mark: |:white\_check\_mark: |Hashes |hExists | +|[hGet](#hGet) |Get the value of a hash field |:white\_check\_mark: |:white\_check\_mark: |Hashes |hGet | +|[hGetAll](#hGetAll) |Get all the fields and values in a hash |:white\_check\_mark: |:white\_check\_mark: |Hashes |hGetAll | +|[hIncrBy](#hIncrBy) |Increment the integer value of a hash field by the given number |:white\_check\_mark: |:white\_check\_mark: |Hashes |hIncrBy | +|[hIncrByFloat](#hIncrByFloat) |Increment the float value of a hash field by the given amount |:white\_check\_mark: |:white\_check\_mark: |Hashes |hIncrByFloat | +|[hKeys](#hKeys) |Get all the fields in a hash |:white\_check\_mark: |:white\_check\_mark: |Hashes |hKeys | +|[hLen](#hLen) |Get the number of fields in a hash |:white\_check\_mark: |:white\_check\_mark: |Hashes |hLen | +|[hMGet](#hMGet) |Get the values of all the given hash fields |:white\_check\_mark: |:white\_check\_mark: |Hashes |hMGet | +|[hMSet](#hMSet) |Set multiple hash fields to multiple values |:white\_check\_mark: |:white\_check\_mark: |Hashes |hMSet | +|[hScan](#hScan) |Scan a hash key for members |:white\_check\_mark: |:white\_check\_mark: |Hashes |hScan | +|[hSet](#hSet) |Set the string value of a hash field |:white\_check\_mark: |:white\_check\_mark: |Hashes |hSet | +|[hSetNx](#hSetNx) |Set the value of a hash field, only if the field does not exist |:white\_check\_mark: |:white\_check\_mark: |Hashes |hSetNx | +|[hStrLen](#hStrLen) |Get the string length of the value associated with field in the hash |:white\_check\_mark: |:white\_check\_mark: |Hashes |hStrLen | +|[hVals](#hVals) |Get all the values in a hash |:white\_check\_mark: |:white\_check\_mark: |Hashes |hVals | + +## Usage + +```php +$valkey = new Valkey(); +$valkey->connect('127.0.0.1', 6379); +$valkey->hSet('hash', 'key1', 'hello'); /* 1, 'key1' => 'hello' in the hash at "h" */ +$valkey->hGet('hash', 'key1'); /* returns "hello" */ +$valkey->hSetNx('hash', 'key1', 'hello'); /* TRUE, 'key1' => 'hello' in the hash at "hash" */ +$valkey->hLen('hash'); /* returns 2 */ +$valkey->hGetAll('hash'); +$valkey->hKeys('hash'); +$valkey->hVals('hash'); +``` + +### hSet +----- +_**Description**_: Adds a value to the hash stored at key. +##### *Parameters* +*key* +*hashKey* +*value* + +##### *Return value* +*LONG* `1` if value didn't exist and was added successfully, `0` if the value was already present and was replaced, `FALSE` if there was an error. +##### *Example* + +```php +$valkey->del('hash') +$valkey->hSet('hash', 'key1', 'hello'); /* 1, 'key1' => 'hello' in the hash at "h" */ +$valkey->hGet('hash', 'key1'); /* returns "hello" */ + +$valkey->hSet('hash', 'key1', 'plop'); /* 0, value was replaced. */ +$valkey->hGet('hash', 'key1'); /* returns "plop" */ +``` + +### hSetNx +----- +_**Description**_: Adds a value to the hash stored at key only if this field isn't already in the hash. + +##### *Return value* +*BOOL* `TRUE` if the field was set, `FALSE` if it was already present. + +##### *Example* + +```php +$valkey->del('hash') +$valkey->hSetNx('hash', 'key1', 'hello'); /* TRUE, 'key1' => 'hello' in the hash at "h" */ +$valkey->hSetNx('hash', 'key1', 'world'); /* FALSE, 'key1' => 'hello' in the hash at "h". No change since the field wasn't replaced. */ +``` + + +### hGet +----- +_**Description**_: Gets a value from the hash stored at key. If the hash table doesn't exist, or the key doesn't exist, `FALSE` is returned. +##### *Parameters* +*key* +*hashKey* + +##### *Return value* +*STRING* The value, if the command executed successfully +*BOOL* `FALSE` in case of failure + + +### hLen +----- +_**Description**_: Returns the length of a hash, in number of items +##### *Parameters* +*key* + +##### *Return value* +*LONG* the number of items in a hash, `FALSE` if the key doesn't exist or isn't a hash. +##### *Example* + +```php +$valkey->del('hash') +$valkey->hSet('hash', 'key1', 'hello'); +$valkey->hSet('hash', 'key2', 'plop'); +$valkey->hLen('hash'); /* returns 2 */ +``` + +### hDel +----- +_**Description**_: Removes a value from the hash stored at key. If the hash table doesn't exist, or the key doesn't exist, `FALSE` is returned. +##### *Parameters* +*key* +*hashKey1* +*hashKey2* +... + +##### *Return value* +*LONG* the number of deleted keys, 0 if the key doesn't exist, `FALSE` if the key isn't a hash. + + +### hKeys +----- +_**Description**_: Returns the keys in a hash, as an array of strings. + +##### *Parameters* +*Key*: key + +##### *Return value* +An array of elements, the keys of the hash. This works like PHP's array_keys(). + +##### *Example* + +```php +$valkey->del('hash'); +$valkey->hSet('hash', 'a', 'x'); +$valkey->hSet('hash', 'b', 'y'); +$valkey->hSet('hash', 'c', 'z'); +$valkey->hSet('hash', 'd', 't'); +var_dump($valkey->hKeys('hash')); +``` + +Output: +``` +array(4) { + [0]=> + string(1) "a" + [1]=> + string(1) "b" + [2]=> + string(1) "c" + [3]=> + string(1) "d" +} +``` +The order is random and corresponds to redis' own internal representation of the set structure. + +### hVals +----- +_**Description**_: Returns the values in a hash, as an array of strings. + +##### *Parameters* +*Key*: key + +##### *Return value* +An array of elements, the values of the hash. This works like PHP's array_values(). + +##### *Example* + +```php +$valkey->del('hash'); +$valkey->hSet('hash', 'a', 'x'); +$valkey->hSet('hash', 'b', 'y'); +$valkey->hSet('hash', 'c', 'z'); +$valkey->hSet('hash', 'd', 't'); +var_dump($valkey->hVals('hash')); +``` + +Output: +``` +array(4) { + [0]=> + string(1) "x" + [1]=> + string(1) "y" + [2]=> + string(1) "z" + [3]=> + string(1) "t" +} +``` +The order is random and corresponds to redis' own internal representation of the set structure. + +### hGetAll +----- +_**Description**_: Returns the whole hash, as an array of strings indexed by strings. + +##### *Parameters* +*Key*: key + +##### *Return value* +An array of elements, the contents of the hash. + +##### *Example* + +```php +$valkey->del('hash'); +$valkey->hSet('hash', 'a', 'x'); +$valkey->hSet('hash', 'b', 'y'); +$valkey->hSet('hash', 'c', 'z'); +$valkey->hSet('hash', 'd', 't'); +var_dump($valkey->hGetAll('hash')); +``` + +Output: +``` +array(4) { + ["a"]=> + string(1) "x" + ["b"]=> + string(1) "y" + ["c"]=> + string(1) "z" + ["d"]=> + string(1) "t" +} +``` +The order is random and corresponds to redis' own internal representation of the set structure. + +### hExists +----- +_**Description**_: Verify if the specified member exists in a key. +##### *Parameters* +*key* +*memberKey* +##### *Return value* +*BOOL*: If the member exists in the hash table, return `TRUE`, otherwise return `FALSE`. +##### *Examples* +```php +$valkey->hSet('hash', 'a', 'x'); +$valkey->hExists('hash', 'a'); /* TRUE */ +$valkey->hExists('hash', 'NonExistingKey'); /* FALSE */ +``` + +### hIncrBy +----- +_**Description**_: Increments the value of a member from a hash by a given amount. +##### *Parameters* +*key* +*member* +*value*: (integer) value that will be added to the member's value +##### *Return value* +*LONG* the new value +##### *Examples* +```php +$valkey->del('hash'); +$valkey->hIncrBy('hash', 'x', 2); /* returns 2: h[x] = 2 now. */ +$valkey->hIncrBy('hash', 'x', 1); /* h[x] ← 2 + 1. Returns 3 */ +``` + +### hIncrByFloat +----- +_**Description**_: Increments the value of a hash member by the provided float value +##### *Parameters* +*key* +*member* +*value*: (float) value that will be added to the member's value +##### *Return value* +*FLOAT* the new value +##### *Examples* +```php +$valkey->del('hash'); +$valkey->hIncrByFloat('hash','x', 1.5); /* returns 1.5: h[x] = 1.5 now */ +$valkey->hIncrByFloat('hash', 'x', 1.5); /* returns 3.0: h[x] = 3.0 now */ +$valkey->hIncrByFloat('hash', 'x', -3.0); /* returns 0.0: h[x] = 0.0 now */ +``` + +### hMSet +----- +_**Description**_: Fills in a whole hash. Non-string values are converted to string, using the standard `(string)` cast. NULL values are stored as empty strings. +##### *Parameters* +*key* +*members*: key → value array +##### *Return value* +*BOOL* +##### *Examples* +```php +$valkey->del('user:1'); +$valkey->hMSet('user:1', ['name' => 'Joe', 'salary' => 2000]); +$valkey->hIncrBy('user:1', 'salary', 100); // Joe earns 100 more now. +``` + +### hMGet +----- +_**Description**_: Retrieve the values associated to the specified fields in the hash. +##### *Parameters* +*key* +*memberKeys* Array +##### *Return value* +*Array* An array of elements, the values of the specified fields in the hash, with the hash keys as array keys. +##### *Examples* +```php +$valkey->del('hash'); +$valkey->hSet('hash', 'field1', 'value1'); +$valkey->hSet('hash', 'field2', 'value2'); +$valkey->hMGet('hash', ['field1', 'field2']); /* returns ['field1' => 'value1', 'field2' => 'value2'] */ +``` + +### hScan +----- +_**Description**_: Scan a HASH value for members, with an optional pattern and count +##### *Parameters* +*key*: String +*iterator*: Long (reference) +*pattern*: Optional pattern to match against +*count*: How many keys to return in a go (only a suggestion to Valkey) +##### *Return value* +*Array* An array of members that match our pattern + +##### *Examples* +```php +$it = NULL; +/* Don't ever return an empty array until we're done iterating */ +$valkey->setOption(Valkey::OPT_SCAN, Valkey::SCAN_RETRY); +while($arr_keys = $valkey->hScan('hash', $it)) { + foreach($arr_keys as $str_field => $str_value) { + echo "$str_field => $str_value\n"; /* Print the hash member and value */ + } +} +``` + +### hStrLen +----- +_**Description**_: Get the string length of the value associated with field in the hash stored at key. +##### *Parameters* +*key*: String +*field*: String +##### *Return value* +*LONG* the string length of the value associated with field, or zero when field is not present in the hash or key does not exist at all. diff --git a/docs/content/hyperloglogs.md b/docs/content/hyperloglogs.md index e69de29bb2..3ec2b5c84f 100644 --- a/docs/content/hyperloglogs.md +++ b/docs/content/hyperloglogs.md @@ -0,0 +1,90 @@ +# Valkey PHP - HyperLogLogs + +|Command |Description |Supported |Tested |Class/Trait |Method | +|--- |--- |:-: |:-: |--- |--- | +|[pfAdd](#pfAdd) |Adds the specified elements to the specified HyperLogLog. |:white\_check\_mark: |:white\_check\_mark: |HyperLogLogs |pfAdd | +|[pfCount](#pfCount) |Return the approximated cardinality of the set(s) observed by the HyperLogLog at key(s). |:white\_check\_mark: |:white\_check\_mark: |HyperLogLogs |pfCount | +|[pfDebug](#pfDebug) |Adds the specified elements to the specified HyperLogLog. |:x: |:white\_check\_mark: |HyperLogLogs |pfDebug | +|[pfMerge](#pfMerge) |Adds the specified elements to the specified HyperLogLog. |:white\_check\_mark: |:white\_check\_mark: |HyperLogLogs |pfMerge | +|[pfSelfTest](#pfSelfTest) |Adds the specified elements to the specified HyperLogLog. |:x: |:x: |HyperLogLogs |pfSelfTest | + +### pfAdd +----- + +_**Description**_: Adds the specified elements to the specified HyperLogLog. + +##### *Prototype* +```php +$valkey->pfAdd($key, Array $elements); +``` + +##### *Parameters* +_Key_ +_Array of values_ + +##### *Return value* +*Integer*: 1 if at least 1 HyperLogLog internal register was altered. 0 otherwise. + +##### *Example* + +```php +$valkey->pfAdd('hll', ['a', 'b', 'c']); // (int) 1 +$valkey->pfAdd('hll', ['a', 'b']); // (int) 0 +``` + +### pfCount +----- + +_**Description**_: Return the approximated cardinality of the set(s) observed by the HyperLogLog at key(s). + +##### *Prototype* +```php +$valkey->pfCount($key); +$valkey->pfCount(Array $keys); +``` + +##### *Parameters* +_Key_ or _Array of keys_ + +##### *Return value* +*Integer*: The approximated number of unique elements observed via [pfAdd](#pfAdd). + +##### *Example* + +```php +$valkey->pfAdd('hll1', ['a', 'b', 'c']); // (int) 1 +$valkey->pfCount('hll1'); // (int) 3 + +$valkey->pfAdd('hll2', ['d', 'e', 'a']); // (int) 1 +$valkey->pfCount('hll2'); // (int) 3 + +$valkey->pfCount(['hll1', 'hll2']); // (int) 5 +``` + +### pfMerge +----- + +_**Description**_: Merge N different HyperLogLogs into a single one. + +##### *Prototype* +```php +$valkey->pfMerge($destkey, Array $sourceKeys); +``` + +##### *Parameters* +_Destination Key_ +_Array of Source Keys_ + +##### *Return value* +*BOOL*: `TRUE` on success, `FALSE` on error. + +##### *Example* + +```php +$valkey->pfAdd('hll1', ['a', 'b', 'c']); // (int) 1 +$valkey->pfAdd('hll2', ['d', 'e', 'a']); // (int) 1 + +$valkey->pfMerge('hll3', ['hll1', 'hll2']); // true + +$valkey->pfCount('hll3'); // (int) 5 +``` \ No newline at end of file diff --git a/docs/content/introspection.md b/docs/content/introspection.md new file mode 100644 index 0000000000..c58f3b8dd2 --- /dev/null +++ b/docs/content/introspection.md @@ -0,0 +1,108 @@ +# Valkey PHP - Introspection + +|Command |Description |Supported |Tested |Class/Trait |Method | +|--- |--- |:-: |:-: |--- |--- | +|[isConnected](#isConnected) |A method to determine if a phpredis object thinks it's connected to a server. |:white\_check\_mark: |:white\_check\_mark: |Introspection |isConnected | +|[getHost](#getHost) |Retrieve our host or unix socket that we're connected to. |:white\_check\_mark: |:white\_check\_mark: |Introspection |getHost | +|[getPort](#getPort) |Get the port we're connected to. |:white\_check\_mark: |:white\_check\_mark: |Introspection |getPort | +|[getDbNum](#getDbNum) |Get the database number phpredis is pointed to. |:white\_check\_mark: |:white\_check\_mark: |Introspection |getDbNum | +|[getTimeout](#getTimeout) |Get the (write) timeout in use for phpredis. |:white\_check\_mark: |:white\_check\_mark: |Introspection |getTimeout | +|[getReadTimeout](#getReadTimeout) |Get the read timeout specified to phpredis or FALSE if we're not connected. |:white\_check\_mark: |:white\_check\_mark: |Introspection |getReadTimeout | +|[getPersistentID](#getPersistentID)|Gets the persistent ID that phpredis is using. |:white\_check\_mark: |:white\_check\_mark: |Introspection |getPersistentID| +|[getAuth](#getAuth) |Get the password used to authenticate the phpredis connection. |:white\_check\_mark: |:white\_check\_mark: |Introspection| getAuth | + +## Usage + +```php +$valkey = new Valkey(); +$valkey->connect('127.0.0.1', 6379); +$valkey->isConnected(); +$valkey->getHost(); +$valkey->getPort(); +$valkey->getDbNum(); +$valkey->getTimeout(); +$valkey->getReadTimeout(); +$valkey->getPersistentID(); +$valkey->getAuth(); +``` + +### isConnected +----- +_**Description**_: A method to determine if a valkey-php object thinks it's connected to a server + +##### *Parameters* +None + +##### *Return value* +*Boolean* Returns TRUE if valkey-php thinks it's connected and FALSE if not + +### getHost +----- +_**Description**_: Retrieve our host or unix socket that we're connected to + +##### *Parameters* +None + +##### *Return value* +*Mixed* The host or unix socket we're connected to or FALSE if we're not connected + + +### getPort +----- +_**Description**_: Get the port we're connected to + +##### *Parameters* +None + +##### *Return value* +*Mixed* Returns the port we're connected to or FALSE if we're not connected + +### getDbNum +----- +_**Description**_: Get the database number valkey-php is pointed to + +##### *Parameters* +None + +##### *Return value* +*Mixed* Returns the database number (LONG) valkey-php thinks it's pointing to or FALSE if we're not connected + +### getTimeout +----- +_**Description**_: Get the (write) timeout in use for valkey-php + +##### *Parameters* +None + +##### *Return value* +*Mixed* The timeout (DOUBLE) specified in our connect call or FALSE if we're not connected + +### getReadTimeout +_**Description**_: Get the read timeout specified to valkey-php or FALSE if we're not connected + +##### *Parameters* +None + +##### *Return value* +*Mixed* Returns the read timeout (which can be set using setOption and Valkey::OPT_READ_TIMEOUT) or FALSE if we're not connected + +### getPersistentID +----- +_**Description**_: Gets the persistent ID that valkey-php is using + +##### *Parameters* +None + +##### *Return value* +*Mixed* Returns the persistent id valkey-php is using (which will only be set if connected with pconnect), NULL if we're not +using a persistent ID, and FALSE if we're not connected + +### getAuth +----- +_**Description**_: Get the password (or username and password if using Valkey 6 ACLs) used to authenticate the connection. + +### *Parameters* +None + +### *Return value* +*Mixed* Returns NULL if no username/password are set, the password string if a password is set, and a `[username, password]` array if authenticated with a username and password. diff --git a/docs/content/keys.md b/docs/content/keys.md index e69de29bb2..cb6bbacfad 100644 --- a/docs/content/keys.md +++ b/docs/content/keys.md @@ -0,0 +1,408 @@ +# Valkey PHP - Keys + +----- + +|Command |Description |Supported |Tested |Class/Trait |Method | +|--- |--- |:-: |:-: |--- |--- | +|[del](#del) |Delete a key [Blocking] |:white\_check\_mark: |:white\_check\_mark: |Keys |del | +|[delete](#delete) |Delete a key [Blocking] |:white\_check\_mark: |:white\_check\_mark: |Keys |delete | +|[dump](#dump) |Return a serialized version of the value stored at the specified key. |:white\_check\_mark: |:white\_check\_mark: |Keys |dump | +|[exists](#exists) |Determine if a key exists |:white\_check\_mark: |:white\_check\_mark: |Keys |exists | +|[expire](#expire) |Set a key's time to live in seconds |:white\_check\_mark: |:white\_check\_mark: |Keys |expire | +|[expireAt](#expireAt) |Set the expiration for a key as a UNIX timestamp |:white\_check\_mark: |:white\_check\_mark: |Keys |pexpireAt | +|[getKeys](#getKeys) |Find all keys matching the given pattern |:white\_check\_mark: |:white\_check\_mark: |Keys |getKeys | +|[keys](#keys) |Find all keys matching the given pattern |:white\_check\_mark: |:white\_check\_mark: |Keys |keys | +|[migrate](#migrate) | Atomically transfer a key from a Redis instance to another one |:white\_check\_mark: |:white\_check\_mark: |Keys |migrate | +|[move](#move) | Move a key to another database |:white\_check\_mark: |:white\_check\_mark: |Keys |move | +|[object](#object) | Inspect the internals of Redis objects |:white\_check\_mark: |:white\_check\_mark: |Keys |object | +|[persist](#persist) | Remove the expiration from a key |:white\_check\_mark: |:white\_check\_mark: |Keys |persist | +|[pexpire](#pexpire) |Set a key's time to live in seconds |:white\_check\_mark: |:white\_check\_mark: |Keys |pexpire | +|[pexpireAt](#pexpireAt) |Set the expiration for a key as a UNIX timestamp with millisecond precision |:white\_check\_mark: |:white\_check\_mark: |Keys |pexpireAt | +|[pttl](#pttl) | Get the time to live for a key |:white\_check\_mark: |:white\_check\_mark: |Keys |pttl | +|[randomKey](#randomKey) | Return a random key from the keyspace |:white\_check\_mark: |:white\_check\_mark: |Keys |randomKey | +|[rename](#rename) | Rename a key |:white\_check\_mark: |:white\_check\_mark: |Keys |rename | +|[renameKey](#renameKey) | Rename a key |:white\_check\_mark: |:white\_check\_mark: |Keys |renameKey | +|[renameNx](#renameNx) | Rename a key, only if the new key does not exist |:white\_check\_mark: |:white\_check\_mark: |Keys |renameNx | +|[restore](#restore) | Create a key using the provided serialized value, previously obtained with dump. |:white\_check\_mark: |:white\_check\_mark: |Keys |restore | +|[scan](#scan) | Scan for keys in the keyspace (Redis >= 2.8.0) |:white\_check\_mark: |:white\_check\_mark: |Keys |scan | +|[setTimeout](#setTimeout) |Set a key's time to live in seconds |:white\_check\_mark: |:white\_check\_mark: |Keys |setTimeout | +|[sort](#sort) | Sort the elements in a list, set or sorted set |:white\_check\_mark: |:white\_check\_mark: |Keys |sort | +|[ttl](#ttl) | Get the time to live for a key |:white\_check\_mark: |:white\_check\_mark: |Keys |ttl | +|[type](#type) | Determine the type stored at key |:white\_check\_mark: |:white\_check\_mark: |Keys |type | +|[unlink](#unlink) |Delete a key [Background] |:white\_check\_mark: |:white\_check\_mark: |Keys |unlink | + +* [del, delete, unlink](#del-delete-unlink) - Delete a key +* [dump](#dump) - Return a serialized version of the value stored at the specified key. +* [exists](#exists) - Determine if a key exists +* [expire, pexpire](#expire-pexpire) - Set a key's time to live in seconds +* [expireAt, pexpireAt](#expireat-pexpireat) - Set the expiration for a key as a UNIX timestamp +* [keys](#keys) - Find all keys matching the given pattern +* [scan](#scan) - Scan for keys in the keyspace (Valkey >= 2.8.0) +* [migrate](#migrate) - Atomically transfer a key from a Valkey instance to another one +* [move](#move) - Move a key to another database +* [object](#object) - Inspect the internals of Valkey objects +* [persist](#persist) - Remove the expiration from a key +* [randomKey](#randomkey) - Return a random key from the keyspace +* [rename](#rename) - Rename a key +* [renameNx](#renamenx) - Rename a key, only if the new key does not exist +* [type](#type) - Determine the type stored at key +* [sort](#sort) - Sort the elements in a list, set or sorted set +* [ttl, pttl](#ttl-pttl) - Get the time to live for a key +* [restore](#restore) - Create a key using the provided serialized value, previously obtained with [dump](#dump). + +## Usage + +```php +$valkey = new Valkey(); +$valkey->connect('127.0.0.1', 6379); +$valkey->del('key'); +$valkey->delete('key'); +$valkey->unlink('key'); +$valkey->dump('key'); +$valkey->exists('key'); +$valkey->expire('key', 123); +$valkey->expireAt('key', 1743016214.623306); +$valkey->keys(); +$valkey->scan(); +$valkey->migrate('key'); +$valkey->move('key'); +$valkey->object('key'); +$valkey->persist('key'); +$valkey->randomKey('key'); +$valkey->rename('key', 'yek'); +$valkey->renameNx('key', 'yek'); +$valkey->type('key'); +$valkey->sort('key'); +$valkey->ttl('key'); +$valkey->restore('key'); +``` + +### dump +----- +_**Description**_: Dump a key out of a redis database, the value of which can later be passed into redis using the RESTORE command. The data +that comes out of DUMP is a binary representation of the key as Valkey stores it. +##### *Parameters* +*key* string +##### *Return value* +The Valkey encoded value of the key, or FALSE if the key doesn't exist +##### *Examples* +```php +$valkey->set('foo', 'bar'); +$val = $valkey->dump('foo'); // $val will be the Valkey encoded key value +``` + +### migrate +----- +_**Description**_: Migrates a key to a different Valkey instance. + +**Note:**: Valkey introduced migrating multiple keys in 3.0.6, so you must have at least +that version in order to call `migrate` with an array of keys. + +##### *Parameters* +*host* string. The destination host +*port* integer. The TCP port to connect to. +*key(s)* string or array. +*destination-db* integer. The target DB. +*timeout* integer. The maximum amount of time given to this transfer. +*copy* boolean, optional. Should we send the COPY flag to redis. +*replace* boolean, optional. Should we send the REPLACE flag to redis +##### *Examples* +```php +$valkey->migrate('backup', 6379, 'foo', 0, 3600); +$valkey->migrate('backup', 6379, 'foo', 0, 3600, true, true); /* copy and replace */ +$valkey->migrate('backup', 6379, 'foo', 0, 3600, false, true); /* just REPLACE flag */ + +/* Migrate multiple keys (requires Valkey >= 3.0.6) +$valkey->migrate('backup', 6379, ['key1', 'key2', 'key3'], 0, 3600); +``` + +### persist +----- +_**Description**_: Remove the expiration timer from a key. + +##### *Parameters* +*Key*: key + +##### *Return value* +*BOOL*: `TRUE` if a timeout was removed, `FALSE` if the key didn’t exist or didn’t have an expiration timer. + +##### *Example* + +```php +$valkey->persist('key'); +``` + +### restore +----- +_**Description**_: Restore a key from the result of a DUMP operation. +##### *Parameters* +*key* string. The key name +*ttl* integer. How long the key should live (if zero, no expire will be set on the key) +*value* string (binary). The Valkey encoded key value (from DUMP) +##### *Examples* +```php +$valkey->set('foo', 'bar'); +$val = $valkey->dump('foo'); +$valkey->restore('bar', 0, $val); // The key 'bar', will now be equal to the key 'foo' +``` + +### sort +----- +_**Description**_: Sort the elements in a list, set or sorted set. + +##### *Parameters* +*Key*: key +*Options*: [key => value, ...] - optional, with the following keys and values: +``` + 'by' => 'some_pattern_*', + 'limit' => [0, 1], + 'get' => 'some_other_pattern_*' or an array of patterns, + 'sort' => 'asc' or 'desc', + 'alpha' => TRUE, + 'store' => 'external-key' +``` +##### *Return value* +An array of values, or a number corresponding to the number of elements stored if that was used. + +##### *Example* + +```php +$valkey->del('s'); +$valkey->sAdd('s', 5); +$valkey->sAdd('s', 4); +$valkey->sAdd('s', 2); +$valkey->sAdd('s', 1); +$valkey->sAdd('s', 3); + +var_dump($valkey->sort('s')); // 1,2,3,4,5 +var_dump($valkey->sort('s', ['sort' => 'desc'])); // 5,4,3,2,1 +var_dump($valkey->sort('s', ['sort' => 'desc', 'store' => 'out'])); // (int)5 +``` + +### ttl, pttl +----- +_**Description**_: Returns the time to live left for a given key in seconds (ttl), or milliseconds (pttl). + +##### *Parameters* +*Key*: key + +##### *Return value* +*LONG*: The time to live in seconds. If the key has no ttl, `-1` will be returned, and `-2` if the key doesn't exist. + +##### *Example* + +```php +$valkey->ttl('key'); +``` + +### randomKey +----- +_**Description**_: Returns a random key. + +##### *Parameters* +None. +##### *Return value* +*STRING*: an existing key in redis. + +##### *Example* + +```php +$key = $valkey->randomKey(); +$surprise = $valkey->get($key); // who knows what's in there. +``` + +### move +----- +_**Description**_: Moves a key to a different database. + +##### *Parameters* +*Key*: key, the key to move. + +*INTEGER*: dbindex, the database number to move the key to. + +##### *Return value* +*BOOL*: `TRUE` in case of success, `FALSE` in case of failure. +##### *Example* + +```php +$valkey->select(0); // switch to DB 0 +$valkey->set('x', '42'); // write 42 to x +$valkey->move('x', 1); // move to DB 1 +$valkey->select(1); // switch to DB 1 +$valkey->get('x'); // will return 42 +``` + +### rename +----- +_**Description**_: Renames a key. +##### *Parameters* +*STRING*: srckey, the key to rename. + +*STRING*: dstkey, the new name for the key. + +##### *Return value* +*BOOL*: `TRUE` in case of success, `FALSE` in case of failure. +##### *Example* + +```php +$valkey->set('x', '42'); +$valkey->rename('x', 'y'); +$valkey->get('y'); // → 42 +$valkey->get('x'); // → `FALSE` +``` + +### renameNx +----- +_**Description**_: Same as rename, but will not replace a key if the destination already exists. This is the same behaviour as setNx. + +### expire, pexpire +----- +_**Description**_: Sets an expiration on a key in either seconds or milliseconds. + +##### *Prototype* +```php +public function expire(string $key, int $seconds, ?string $mode = NULL): Valkey|bool; +public function pexpire(string $key, int $milliseconds, ?string $mode = NULL): Valkey|bool; +``` + +##### *Return value* +*BOOL*: `TRUE` if an expiration was set, and `FALSE` on failure or if one was not set. You can distinguish between an error and an expiration not being set by checking `getLastError()`. +##### *Example* + +```php +$valkey->set('x', '42'); +$valkey->expire('x', 3); // x will disappear in 3 seconds. +sleep(5); // wait 5 seconds +$valkey->get('x'); // will return `FALSE`, as 'x' has expired. +``` + +### expireAt, pexpireAt +----- +_**Description**_: Seta specific timestamp for a key to expire in seconds or milliseconds. + +##### *Prototype* +```php +public function expireat(string $key, int $unix_timestamp, ?string $mode = NULL): Valkey|bool; +public function pexpireat(string $key, int $unix_timestamp_millis, ?string $mode = NULL): Valkey|bool; +``` + +##### *Return value* +*BOOL*: `TRUE` if an expiration was set and `FALSE` if one was not set or in the event on an error. You can detect an actual error by checking `getLastError()`. + +##### *Example* + +```php +$valkey->set('x', '42'); +$valkey->expireAt('x', time(NULL) + 3); // x will disappear in 3 seconds. +sleep(5); // wait 5 seconds +$valkey->get('x'); // will return `FALSE`, as 'x' has expired. +``` + +### keys +----- +_**Description**_: Returns the keys that match a certain pattern. + +##### *Parameters* +*STRING*: pattern, using '*' as a wildcard. + +##### *Return value* +*Array of STRING*: The keys that match a certain pattern. + +##### *Example* + +```php +$allKeys = $valkey->keys('*'); // all keys will match this. +$keyWithUserPrefix = $valkey->keys('user*'); +``` + +### scan +----- +_**Description**_: Scan the keyspace for keys + +##### *Parameters* +*LONG (reference)*: Iterator, initialized to NULL +*STRING, Optional*: Pattern to match +*LONG, Optional*: Count of keys per iteration (only a suggestion to Valkey) + +##### *Return value* +*Array, boolean*: This function will return an array of keys or FALSE if Valkey returned zero keys + +*Note*: SCAN is a "directed node" command in [ValkeyCluster](cluster.md#directed-node-commands) + +##### *Example* + +```php + +/* Without enabling Valkey::SCAN_RETRY (default condition) */ +$it = NULL; +do { + // Scan for some keys + $arr_keys = $valkey->scan($it); + + // Valkey may return empty results, so protect against that + if ($arr_keys !== FALSE) { + foreach($arr_keys as $str_key) { + echo "Here is a key: $str_key\n"; + } + } +} while ($it > 0); +echo "No more keys to scan!\n"; + +/* With Valkey::SCAN_RETRY enabled */ +$valkey->setOption(Valkey::OPT_SCAN, Valkey::SCAN_RETRY); +$it = NULL; + +/* valkey-php will retry the SCAN command if empty results are returned from the + server, so no empty results check is required. */ +while ($arr_keys = $valkey->scan($it)) { + foreach ($arr_keys as $str_key) { + echo "Here is a key: $str_key\n"; + } +} +echo "No more keys to scan!\n"; +``` + +### object +----- +_**Description**_: Describes the object pointed to by a key. + +##### *Parameters* +The information to retrieve (string) and the key (string). Info can be one of the following: + +* "encoding" +* "refcount" +* "idletime" + +##### *Return value* +*STRING* for "encoding", *LONG* for "refcount" and "idletime", `FALSE` if the key doesn't exist. + +##### *Example* + +```php +$valkey->object("encoding", "l"); // → ziplist +$valkey->object("refcount", "l"); // → 1 +$valkey->object("idletime", "l"); // → 400 (in seconds, with a precision of 10 seconds). +``` + +### type +----- +_**Description**_: Returns the type of data pointed by a given key. + +##### *Parameters* +*Key*: key + +##### *Return value* + +Depending on the type of the data pointed by the key, this method will return the following value: +string: Valkey::VALKEY_STRING +set: Valkey::VALKEY_SET +list: Valkey::VALKEY_LIST +zset: Valkey::VALKEY_ZSET +hash: Valkey::VALKEY_HASH +other: Valkey::VALKEY_NOT_FOUND + +##### *Example* + +```php +$valkey->type('key'); +``` diff --git a/docs/content/lists.md b/docs/content/lists.md index e69de29bb2..784252cfe9 100644 --- a/docs/content/lists.md +++ b/docs/content/lists.md @@ -0,0 +1,498 @@ +# Valkey PHP - Lists + +|Command |Description |Supported |Tested |Class/Trait |Method | +|--- |--- |:-: |:-: |--- |--- | +|[blPop](#blPop) |Remove and get the first element in a list |:white\_check\_mark: |:white\_check\_mark: |Lists |blPop | +|[brPop](#brPop) |Remove and get the last element in a list |:white\_check\_mark: |:white\_check\_mark: |Lists |brPop | +|[bRPopLPush](#bRPopLPush) |Pop a value from a list, push it to another list and return it |:white\_check\_mark: |:white\_check\_mark: |Lists |bRPopLPush | +|[lIndex](#lIndex) |Get an element from a list by its index |:white\_check\_mark: |:white\_check\_mark: |Lists |lIndex | +|[lGet](#lGet) |Get an element from a list by its index |:white\_check\_mark: |:white\_check\_mark: |Lists |lGet | +|[lInsert](#lInsert) |Insert an element before or after another element in a list |:white\_check\_mark: |:white\_check\_mark: |Lists |lInsert | +|[lLen](#lLen) |Get the length/size of a list |:white\_check\_mark: |:white\_check\_mark: |Lists |lLen | +|[lSize](#lSize) |Get the length/size of a list |:white\_check\_mark: |:white\_check\_mark: |Lists |lSize | +|[lPop](#lPop) |Remove and get the first element in a list |:white\_check\_mark: |:white\_check\_mark: |Lists |lPop | +|[lPush](#lPush) |Prepend one or multiple values to a list |:white\_check\_mark: |:white\_check\_mark: |Lists |lPush | +|[lPushx](#lPushx) |Prepend a value to a list, only if the list exists |:white\_check\_mark: |:white\_check\_mark: |Lists |lPushx | +|[lRange](#lRange) |Get a range of elements from a list |:white\_check\_mark: |:white\_check\_mark: |Lists |lRange | +|[lGetRange](#lGetRange) |Get a range of elements from a list |:white\_check\_mark: |:white\_check\_mark: |Lists |lGetRange | +|[lRem](#lRem) |Remove elements from a list |:white\_check\_mark: |:white\_check\_mark: |Lists |lRem | +|[lRemove](#lRemove) |Remove elements from a list |:white\_check\_mark: |:white\_check\_mark: |Lists |lRemove | +|[lSet](#lSet) |Set the value of an element in a list by its index |:white\_check\_mark: |:white\_check\_mark: |Lists |lSet | +|[lTrim](#lTrim) |Trim a list to the specified range |:white\_check\_mark: |:white\_check\_mark: |Lists |lTrim | +|[listTrim](#listTrim) |Trim a list to the specified range |:white\_check\_mark: |:white\_check\_mark: |Lists |listTrim | +|[rPop](#rPop) |Remove and get the last element in a list |:white\_check\_mark: |:white\_check\_mark: |Lists |rPop | +|[rPopLPush](#rPopLPush) |Remove the last element in a list, append it to another list and return it (redis >= 1.1) |:white\_check\_mark: |:white\_check\_mark: |Lists |rPopLPush | +|[rPush](#rPush) |Append one or multiple values to a list |:white\_check\_mark: |:white\_check\_mark: |Lists |rPush | +|[rPushX](#rPushX) |Append a value to a list, only if the list exists |:white\_check\_mark: |:white\_check\_mark: |Lists |rPushX | + +BLMOVE Pops an element from a list, pushes it to another list and returns it. Blocks until an element is available otherwise. Deletes the list if the last element was moved. +BLMPOP Pops the first element from one of multiple lists. Blocks until an element is available otherwise. Deletes the list if the last element was popped. +BLPOP Removes and returns the first element in a list. Blocks until an element is available otherwise. Deletes the list if the last element was popped. +BRPOP Removes and returns the last element in a list. Blocks until an element is available otherwise. Deletes the list if the last element was popped. +BRPOPLPUSH Pops an element from a list, pushes it to another list and returns it. Block until an element is available otherwise. Deletes the list if the last element was popped. +LINDEX Returns an element from a list by its index. +LINSERT Inserts an element before or after another element in a list. +LLEN Returns the length of a list. +LMOVE Returns an element after popping it from one list and pushing it to another. Deletes the list if the last element was moved. +LMPOP Returns multiple elements from a list after removing them. Deletes the list if the last element was popped. +LPOP Returns the first elements in a list after removing it. Deletes the list if the last element was popped. +LPOS Returns the index of matching elements in a list. +LPUSH Prepends one or more elements to a list. Creates the key if it doesn't exist. +LPUSHX Prepends one or more elements to a list only when the list exists. +LRANGE Returns a range of elements from a list. +LREM Removes elements from a list. Deletes the list if the last element was removed. +LSET Sets the value of an element in a list by its index. +LTRIM Removes elements from both ends a list. Deletes the list if all elements were trimmed. +RPOP Returns and removes the last elements of a list. Deletes the list if the last element was popped. +RPOPLPUSH Returns the last element of a list after removing and pushing it to another list. Deletes the list if the last element was popped. +RPUSH Appends one or more elements to a list. Creates the key if it doesn't exist. +RPUSHX Appends an element to a list only when the list exists. + +* [blPop, brPop](#blpop-brpop) - Remove and get the first/last element in a list +* [bRPopLPush](#brpoplpush) - Pop a value from a list, push it to another list and return it +* [lIndex](#lindex) - Get an element from a list by its index +* [lInsert](#linsert) - Insert an element before or after another element in a list +* [lLen](#llen) - Get the length/size of a list +* [lPop](#lpop) - Remove and get the first element in a list +* [lPush](#lpush) - Prepend one or multiple values to a list +* [lPushx](#lpushx) - Prepend a value to a list, only if the list exists +* [lRange](#lrange) - Get a range of elements from a list +* [lRem](#lrem) - Remove elements from a list +* [lSet](#lset) - Set the value of an element in a list by its index +* [lTrim](#ltrim) - Trim a list to the specified range +* [rPop](#rpop) - Remove and get the last element in a list +* [rPopLPush](#rpoplpush) - Remove the last element in a list, append it to another list and return it (redis >= 1.1) +* [rPush](#rpush) - Append one or multiple values to a list +* [rPushX](#rpushx) - Append a value to a list, only if the list exists + +## Usage + +```php +$valkey = new Valkey(); +$valkey->connect('127.0.0.1', 6379); +/* Non blocking feature */ +$valkey->lPush('key1', 'A'); +$valkey->del('key2'); +$valkey->blPop('key1', 'key2', 10); /* ['key1', 'A'] */ +$valkey->rPush('key1', 'A'); +$valkey->lInsert('key1', Valkey::AFTER, 'A', 'X'); /* 0 */ +$valkey->lRange('key1', 0, -1); /* ['A', 'B', 'X', 'C'] */ +``` + +### blPop, brPop +----- +_**Description**_: Is a blocking lPop(rPop) primitive. If at least one of the lists contains at least one element, the element will be popped from the head of the list and returned to the caller. +If all the list identified by the keys passed in arguments are empty, blPop will block during the specified timeout until an element is pushed to one of those lists. This element will be popped. + +##### *Parameters* +*ARRAY* Array containing the keys of the lists +*INTEGER* Timeout +Or +*STRING* Key1 +*STRING* Key2 +*STRING* Key3 +... +*STRING* Keyn +*INTEGER* Timeout + +##### *Return value* +*ARRAY* ['listName', 'element'] + +##### *Example* + +```php +/* Non blocking feature */ +$valkey->lPush('key1', 'A'); +$valkey->del('key2'); + +$valkey->blPop('key1', 'key2', 10); /* ['key1', 'A'] */ +/* OR */ +$valkey->blPop(['key1', 'key2'], 10); /* ['key1', 'A'] */ + +$valkey->brPop('key1', 'key2', 10); /* ['key1', 'A'] */ +/* OR */ +$valkey->brPop(['key1', 'key2'], 10); /* ['key1', 'A'] */ + +/* Blocking feature */ + +/* process 1 */ +$valkey->del('key1'); +$valkey->blPop('key1', 10); +/* blocking for 10 seconds */ + +/* process 2 */ +$valkey->lPush('key1', 'A'); + +/* process 1 */ +/* ['key1', 'A'] is returned*/ +``` + +### bRPopLPush +----- +_**Description**_: A blocking version of `rPopLPush`, with an integral timeout in the third parameter. + +##### *Parameters* +*Key*: srckey +*Key*: dstkey +*Long*: timeout + +##### *Return value* +*STRING* The element that was moved in case of success, `FALSE` in case of timeout. + +### lIndex +----- +_**Description**_: Return the specified element of the list stored at the specified key. + +0 the first element, 1 the second ... +-1 the last element, -2 the penultimate ... + +Return `FALSE` in case of a bad index or a key that doesn't point to a list. + +##### *Parameters* +*key* +*index* + +##### *Return value* +*String* the element at this index +*Bool* `FALSE` if the key identifies a non-string data type, or no value corresponds to this index in the list `Key`. + +##### *Example* + +```php +$valkey->rPush('key1', 'A'); +$valkey->rPush('key1', 'B'); +$valkey->rPush('key1', 'C'); /* key1 => [ 'A', 'B', 'C' ] */ +$valkey->lindex('key1', 0); /* 'A' */ +$valkey->lindex('key1', -1); /* 'C' */ +$valkey->lindex('key1', 10); /* `FALSE` */ +``` + +### lInsert +----- +_**Description**_: Insert value in the list before or after the pivot value. + +The parameter options specify the position of the insert (before or after). +If the list didn't exists, or the pivot didn't exists, the value is not inserted. + +##### *Parameters* +*key* +*position* Valkey::BEFORE | Valkey::AFTER +*pivot* +*value* + +##### *Return value* +The number of the elements in the list, -1 if the pivot didn't exists. + +##### *Example* + +```php +$valkey->del('key1'); +$valkey->lInsert('key1', Valkey::AFTER, 'A', 'X'); /* 0 */ + +$valkey->lPush('key1', 'A'); +$valkey->lPush('key1', 'B'); +$valkey->lPush('key1', 'C'); + +$valkey->lInsert('key1', Valkey::BEFORE, 'C', 'X'); /* 4 */ +$valkey->lRange('key1', 0, -1); /* ['A', 'B', 'X', 'C'] */ + +$valkey->lInsert('key1', Valkey::AFTER, 'C', 'Y'); /* 5 */ +$valkey->lRange('key1', 0, -1); /* ['A', 'B', 'X', 'C', 'Y'] */ + +$valkey->lInsert('key1', Valkey::AFTER, 'W', 'value'); /* -1 */ +``` + +### lPop +----- +_**Description**_: Return and remove the first element of the list. + +##### *Parameters* +*key* + +##### *Return value* +*STRING* if command executed successfully +*BOOL* `FALSE` in case of failure (empty list) + +##### *Example* + +```php +$valkey->rPush('key1', 'A'); +$valkey->rPush('key1', 'B'); +$valkey->rPush('key1', 'C'); /* key1 => [ 'A', 'B', 'C' ] */ +$valkey->lPop('key1'); /* key1 => [ 'B', 'C' ] */ +``` + +### lPush +----- +_**Description**_: Adds one or more values to the head of a LIST. Creates the list if the key didn't exist. If the key exists and is not a list, `FALSE` is returned. + +##### *Prototype* +```php +$valkey->lPush($key, $entry [, $entry, $entry]); +``` + +##### *Return value* +*LONG* The new length of the list in case of success, `FALSE` in case of Failure. + +##### *Examples* +```php +$valkey->del('key1'); +$valkey->lPush('key1', 'F'); // returns 1 +$valkey->lPush('key1', 'E'); // returns 2 +$valkey->lPush('key1', 'D'); // returns 3 +/* key1 now contains: [ 'D', 'E', 'F' ] */ + +$valkey->lPush('key1', 'C', 'B', 'A'); // Returns 6 +/* key1 now contains: [ 'A', 'B', 'C', 'D', 'E', 'F' ] +``` + +### lPushx +----- +_**Description**_: Adds the string value to the head (left) of the list if the list exists. + +##### *Parameters* +*key* +*value* String, value to push in key + +##### *Return value* +*LONG* The new length of the list in case of success, `FALSE` in case of Failure. + +##### *Examples* +```php +$valkey->del('key1'); +$valkey->lPushx('key1', 'A'); // returns 0 +$valkey->lPush('key1', 'A'); // returns 1 +$valkey->lPushx('key1', 'B'); // returns 2 +$valkey->lPushx('key1', 'C'); // returns 3 +/* key1 now points to the following list: [ 'A', 'B', 'C' ] */ +``` + +### lRange +----- +_**Description**_: Returns the specified elements of the list stored at the specified key in the range [start, end]. start and stop are interpreted as indices: +0 the first element, 1 the second ... +-1 the last element, -2 the penultimate ... + +##### *Parameters* +*key* +*start* +*end* + +##### *Return value* +*Array* containing the values in specified range. + +##### *Example* + +```php +$valkey->rPush('key1', 'A'); +$valkey->rPush('key1', 'B'); +$valkey->rPush('key1', 'C'); +$valkey->lRange('key1', 0, -1); /* ['A', 'B', 'C'] */ +``` + +### lRem +----- +_**Description**_: Removes the first `count` occurrences of the value element from the list. If count is zero, all the matching elements are removed. If count is negative, elements are removed from tail to head. + +**Note**: The argument order is not the same as in the Valkey documentation. This difference is kept for compatibility reasons. + +##### *Parameters* +*key* +*value* +*count* + +##### *Return value* +*LONG* the number of elements to remove +*BOOL* `FALSE` if the value identified by key is not a list. + +##### *Example* + +```php +$valkey->lPush('key1', 'A'); +$valkey->lPush('key1', 'B'); +$valkey->lPush('key1', 'C'); +$valkey->lPush('key1', 'A'); +$valkey->lPush('key1', 'A'); + +$valkey->lRange('key1', 0, -1); /* ['A', 'A', 'C', 'B', 'A'] */ +$valkey->lRem('key1', 'A', 2); /* 2 */ +$valkey->lRange('key1', 0, -1); /* ['C', 'B', 'A'] */ +``` + +### lSet +----- +_**Description**_: Set the list at index with the new value. + +##### *Parameters* +*key* +*index* +*value* + +##### *Return value* +*BOOL* `TRUE` if the new value was set. `FALSE` if the index is out of range, or data type identified by key is not a list. + +##### *Example* + +```php +$valkey->rPush('key1', 'A'); +$valkey->rPush('key1', 'B'); +$valkey->rPush('key1', 'C'); /* key1 => [ 'A', 'B', 'C' ] */ +$valkey->lindex('key1', 0); /* 'A' */ +$valkey->lSet('key1', 0, 'X'); +$valkey->lindex('key1', 0); /* 'X' */ +``` + +### lTrim +----- +_**Description**_: Trims an existing list so that it will contain only a specified range of elements. + +##### *Parameters* +*key* +*start* +*stop* + +##### *Return value* +*Array* +*Bool* return `FALSE` if the key identify a non-list value. + +##### *Example* + +```php +$valkey->rPush('key1', 'A'); +$valkey->rPush('key1', 'B'); +$valkey->rPush('key1', 'C'); +$valkey->lRange('key1', 0, -1); /* ['A', 'B', 'C'] */ +$valkey->lTrim('key1', 0, 1); +$valkey->lRange('key1', 0, -1); /* ['A', 'B'] */ +``` + +### rPop +----- +_**Description**_: Returns and removes the last element of the list. + +##### *Parameters* +*key* + +##### *Return value* +*STRING* if command executed successfully +*BOOL* `FALSE` in case of failure (empty list) + +##### *Example* + +```php +$valkey->rPush('key1', 'A'); +$valkey->rPush('key1', 'B'); +$valkey->rPush('key1', 'C'); /* key1 => [ 'A', 'B', 'C' ] */ +$valkey->rPop('key1'); /* key1 => [ 'A', 'B' ] */ +``` + +### rPopLPush +----- +_**Description**_: Pops a value from the tail of a list, and pushes it to the front of another list. Also return this value. (redis >= 1.1) + +##### *Parameters* +*Key*: srckey +*Key*: dstkey + +##### *Return value* +*STRING* The element that was moved in case of success, `FALSE` in case of failure. + +##### *Example* + +```php +$valkey->del('x', 'y'); + +$valkey->lPush('x', 'abc'); +$valkey->lPush('x', 'def'); +$valkey->lPush('y', '123'); +$valkey->lPush('y', '456'); + +// move the last of x to the front of y. +var_dump($valkey->rPopLPush('x', 'y')); +var_dump($valkey->lRange('x', 0, -1)); +var_dump($valkey->lRange('y', 0, -1)); + +``` +Output: +``` +string(3) "abc" +array(1) { + [0]=> + string(3) "def" +} +array(3) { + [0]=> + string(3) "abc" + [1]=> + string(3) "456" + [2]=> + string(3) "123" +} +``` + +### rPush +----- +_**Description**_: Adds one or more entries to the tail of a LIST. Valkey will create the list if it doesn't exist. + +##### *Prototype* +```php +$valkey->rPush($key, $entry [, $entry, $entry]); +``` + +##### *Return value* +*LONG* The new length of the list in case of success, `FALSE` in case of Failure. + +##### *Examples* +```php +$valkey->del('key1'); +$valkey->rPush('key1', 'A'); // returns 1 +$valkey->rPush('key1', 'B'); // returns 2 +$valkey->rPush('key1', 'C'); // returns 3 +$valkey->rPush('key1', 'D', 'E', 'F'); // returns 6 +/* key1 now contains: [ 'A', 'B', 'C', 'D', 'E', 'F' ] */ +``` + +### rPushX +----- +_**Description**_: Adds the string value to the tail (right) of the list if the list exists. `FALSE` in case of Failure. + +##### *Parameters* +*key* +*value* String, value to push in key + +##### *Return value* +*LONG* The new length of the list in case of success, `FALSE` in case of Failure. + +##### *Examples* +```php +$valkey->del('key1'); +$valkey->rPushX('key1', 'A'); // returns 0 +$valkey->rPush('key1', 'A'); // returns 1 +$valkey->rPushX('key1', 'B'); // returns 2 +$valkey->rPushX('key1', 'C'); // returns 3 +/* key1 now points to the following list: [ 'A', 'B', 'C' ] */ +``` + +### lLen +----- +_**Description**_: Returns the size of a list identified by Key. + +If the list didn't exist or is empty, the command returns 0. If the data type identified by Key is not a list, the command return `FALSE`. + +##### *Parameters* +*Key* + +##### *Return value* +*LONG* The size of the list identified by Key exists. +*BOOL* `FALSE` if the data type identified by Key is not list + +##### *Example* + +```php +$valkey->rPush('key1', 'A'); +$valkey->rPush('key1', 'B'); +$valkey->rPush('key1', 'C'); /* key1 => [ 'A', 'B', 'C' ] */ +$valkey->lLen('key1');/* 3 */ +$valkey->rPop('key1'); +$valkey->lLen('key1');/* 2 */ +``` \ No newline at end of file diff --git a/docs/content/pub-sub.md b/docs/content/pub-sub.md new file mode 100644 index 0000000000..7899802936 --- /dev/null +++ b/docs/content/pub-sub.md @@ -0,0 +1,128 @@ +# Valkey PHP - Pub/sub + +|Command |Description |Supported |Tested |Class/Trait |Method | +|--- |--- |:-: |:-: |--- |--- | +|[pSubscribe](#pSubscribe) |Subscribe to channels by pattern |:x: |:x: |PubSub |pSubscribe | +|[publish](#publish) |Post a message to a channel |:x: |:x: |PubSub |publish | +|[subscribe](#subscribe) |Subscribe to channels |:x: |:x: |PubSub |subscribe | +|[pubSub](#pubSub) |Introspection into the pub/sub subsystem |:x: |:x: |PubSub |pubSub | + +PSUBSCRIBE Listens for messages published to channels that match one or more patterns. +PUBLISH Posts a message to a channel. +PUBSUB A container for Pub/Sub commands. +PUBSUB CHANNELS Returns the active channels. +PUBSUB HELP Returns helpful text about the different subcommands. +PUBSUB NUMPAT Returns a count of unique pattern subscriptions. +PUBSUB NUMSUB Returns a count of subscribers to channels. +PUBSUB SHARDCHANNELS Returns the active shard channels. +PUBSUB SHARDNUMSUB Returns the count of subscribers of shard channels. +PUNSUBSCRIBE Stops listening to messages published to channels that match one or more patterns. +SPUBLISH Post a message to a shard channel +SSUBSCRIBE Listens for messages published to shard channels. +SUBSCRIBE Listens for messages published to channels. +SUNSUBSCRIBE Stops listening to messages posted to shard channels. +UNSUBSCRIBE Stops listening to messages posted to channels. + +* [pSubscribe](#psubscribe) - Subscribe to channels by pattern +* [publish](#publish) - Post a message to a channel +* [subscribe](#subscribe) - Subscribe to channels +* [pubSub](#pubsub) - Introspection into the pub/sub subsystem + +## Usage + +```php +$valkey = new Valkey(); +$valkey->connect('127.0.0.1', 6379); +$valkey->eval("return 1"); // Returns an integer: 1 +$valkey->eval("return {1,2,3}"); // Returns [1,2,3] +$valkey->del('mylist'); +$valkey->rpush('mylist','a'); +$valkey->rpush('mylist','b'); +$valkey->rpush('mylist','c'); +// Nested response: [1,2,3,['a','b','c']]; +$valkey->eval("return {1,2,3,redis.call('lrange','mylist',0,-1)}"); +``` + +### pSubscribe +----- +_**Description**_: Subscribe to channels by pattern + +##### *Parameters* +*patterns*: An array of patterns to match +*callback*: Either a string or an array with an object and method. The callback will get four arguments ($redis, $pattern, $channel, $message) +*return value*: Mixed. Any non-null return value in the callback will be returned to the caller. +##### *Example* + +```php +function pSubscribe($redis, $pattern, $chan, $msg) { + echo "Pattern: $pattern\n"; + echo "Channel: $chan\n"; + echo "Payload: $msg\n"; +} +``` + +### publish +----- +_**Description**_: Publish messages to channels. Warning: this function will probably change in the future. + +##### *Parameters* +*channel*: a channel to publish to +*message*: string + +##### *Example* + +```php +$valkey->publish('chan-1', 'hello, world!'); // send message. +``` + +### subscribe +----- +_**Description**_: Subscribe to channels. Warning: this function will probably change in the future. + +##### *Parameters* +*channels*: an array of channels to subscribe to +*callback*: either a string or [$instance, 'method_name']. The callback function receives 3 parameters: the redis instance, the channel name, and the message. +*return value*: Mixed. Any non-null return value in the callback will be returned to the caller. +##### *Example* + +```php +function f($redis, $chan, $msg) { + switch($chan) { + case 'chan-1': + ... + break; + + case 'chan-2': + ... + break; + + case 'chan-2': + ... + break; + } +} + +$valkey->subscribe(['chan-1', 'chan-2', 'chan-3'], 'f'); // subscribe to 3 chans +``` + +### pubSub +----- +_**Description**_: A command allowing you to get information on the Valkey pub/sub system. + +##### *Parameters* +*keyword*: String, which can be: "channels", "numsub", or "numpat" +*argument*: Optional, variant. For the "channels" subcommand, you can pass a string pattern. For "numsub" an array of channel names. + +##### *Return value* +*CHANNELS*: Returns an array where the members are the matching channels. +*NUMSUB*: Returns a key/value array where the keys are channel names and values are their counts. +*NUMPAT*: Integer return containing the number active pattern subscriptions + +##### *Example* + +```php +$valkey->pubSub("channels"); /*All channels */ +$valkey->pubSub("channels", "*pattern*"); /* Just channels matching your pattern */ +$valkey->pubSub("numsub", ["chan1", "chan2"]); /*Get subscriber counts for 'chan1' and 'chan2'*/ +$valkey->pubSub("numpat"); /* Get the number of pattern subscribers */ +``` diff --git a/docs/content/pubsub.md b/docs/content/pubsub.md deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/docs/content/retry-backoff.md b/docs/content/retry-backoff.md new file mode 100644 index 0000000000..33eb36db15 --- /dev/null +++ b/docs/content/retry-backoff.md @@ -0,0 +1,35 @@ +## Retry and backoff + +1. [Maximum retries](#maximum-retries) +1. [Backoff algorithms](#backoff-algorithms) + +### Maximum retries +You can set and get the maximum retries upon connection issues using the `OPT_MAX_RETRIES` option. Note that this is the number of _retries_, meaning if you set this option to _n_, there will be a maximum _n+1_ attempts overall. Defaults to 10. + +##### *Example* + +```php +$valkey->setOption(Valkey::OPT_MAX_RETRIES, 5); +$valkey->getOption(Valkey::OPT_MAX_RETRIES); +``` + +### Backoff algorithms +You can set the backoff algorithm using the `Valkey::OPT_BACKOFF_ALGORITHM` option and choose among the following algorithms described in this blog post by Marc Brooker from AWS: [Exponential Backoff And Jitter](https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter): + +* Default: `Valkey::BACKOFF_ALGORITHM_DEFAULT` +* Decorrelated jitter: `Valkey::BACKOFF_ALGORITHM_DECORRELATED_JITTER` +* Full jitter: `Valkey::BACKOFF_ALGORITHM_FULL_JITTER` +* Equal jitter: `Valkey::BACKOFF_ALGORITHM_EQUAL_JITTER` +* Exponential: `Valkey::BACKOFF_ALGORITHM_EXPONENTIAL` +* Uniform: `Valkey::BACKOFF_ALGORITHM_UNIFORM` +* Constant: `Valkey::BACKOFF_ALGORITHM_CONSTANT` + +These algorithms depend on the _base_ and _cap_ parameters, both in milliseconds, which you can set using the `Valkey::OPT_BACKOFF_BASE` and `Valkey::OPT_BACKOFF_CAP` options, respectively. + +##### *Example* + +```php +$valkey->setOption(Valkey::OPT_BACKOFF_ALGORITHM, Valkey::BACKOFF_ALGORITHM_DECORRELATED_JITTER); +$valkey->setOption(Valkey::OPT_BACKOFF_BASE, 500); // base for backoff computation: 500ms +$valkey->setOption(Valkey::OPT_BACKOFF_CAP, 750); // backoff time capped at 750ms +``` \ No newline at end of file diff --git a/docs/content/scripting.md b/docs/content/scripting.md index e69de29bb2..551d262c8b 100644 --- a/docs/content/scripting.md +++ b/docs/content/scripting.md @@ -0,0 +1,234 @@ +# Valkey PHP - Scripting + +|Command |Description |Supported |Tested |Class/Trait |Method | +|--- |--- |:-: |:-: |--- |--- | +|[eval](#eval) |Evaluate a LUA script serverside. |:white\_check\_mark: |:white\_check\_mark: |Scripting |eval | +|[evalSha](#evalSha) |Evaluate a LUA script serverside, from the SHA1 hash of the script instead of the script itself. |:white\_check\_mark: |:white\_check\_mark: |Scripting |evalSha | +|[script](#script) |Execute the Redis SCRIPT command to perform various operations on the scripting subsystem. |:white\_check\_mark: |:white\_check\_mark: |Scripting |script | +|[getLastError](#getLastError) |The last error message (if any). |:white\_check\_mark: |:white\_check\_mark: |Scripting |getLastError | +|[clearLastError](#clearLastError) |Clear the last error message. |:white\_check\_mark: |:white\_check\_mark: |Scripting |clearLastError | +|[\_prefix](#prefix) |A utility method to prefix the value with the prefix setting for phpredis. |:white\_check\_mark: |:white\_check\_mark: |Scripting |\_prefix | +|[\_unserialize](#unserialize) |A utility method to unserialize data with whatever serializer is set up. |:white\_check\_mark: |:white\_check\_mark: |Scripting |\_unserialize | +|[\_serialize](#serialize) |A utility method to serialize data with whatever serializer is set up. |:white\_check\_mark: |:white\_check\_mark: |Scripting |\_serialize | + +EVAL Executes a server-side Lua script. +EVALSHA Executes a server-side Lua script by SHA1 digest. +EVALSHA_RO Executes a read-only server-side Lua script by SHA1 digest. +EVAL_RO Executes a read-only server-side Lua script. +FCALL Invokes a function. +FCALL_RO Invokes a read-only function. +FUNCTION A container for function commands. +FUNCTION DELETE Deletes a library and its functions. +FUNCTION DUMP Dumps all libraries into a serialized binary payload. +FUNCTION FLUSH Deletes all libraries and functions. +FUNCTION HELP Returns helpful text about the different subcommands. +FUNCTION KILL Terminates a function during execution. +FUNCTION LIST Returns information about all libraries. +FUNCTION LOAD Creates a library. +FUNCTION RESTORE Restores all libraries from a payload. +FUNCTION STATS Returns information about a function during execution. +SCRIPT A container for Lua scripts management commands. +SCRIPT DEBUG Sets the debug mode of server-side Lua scripts. +SCRIPT EXISTS Determines whether server-side Lua scripts exist in the script cache. +SCRIPT FLUSH Removes all server-side Lua scripts from the script cache. +SCRIPT HELP Returns helpful text about the different subcommands. +SCRIPT KILL Terminates a server-side Lua script during execution. +SCRIPT LOAD Loads a server-side Lua script to the script cache. +SCRIPT SHOW Show server-side Lua script in the script cache. + +* [eval](#eval) - Evaluate a LUA script serverside +* [evalSha](#evalsha) - Evaluate a LUA script serverside, from the SHA1 hash of the script instead of the script itself +* [script](#script) - Execute the Valkey SCRIPT command to perform various operations on the scripting subsystem +* [getLastError](#getlasterror) - The last error message (if any) +* [clearLastError](#clearlasterror) - Clear the last error message +* [_prefix](#_prefix) - A utility method to prefix the value with the prefix setting for valkey-php +* [_unserialize](#_unserialize) - A utility method to unserialize data with whatever serializer is set up +* [_serialize](#_serialize) - A utility method to serialize data with whatever serializer is set up + +### eval +----- +_**Description**_: Evaluate a LUA script serverside + +##### *Parameters* +*script* string. +*args* array, optional. +*num_keys* int, optional. + +##### *Return value* +Mixed. What is returned depends on what the LUA script itself returns, which could be a scalar value (int/string), or an array. +Arrays that are returned can also contain other arrays, if that's how it was set up in your LUA script. If there is an error +executing the LUA script, the getLastError() function can tell you the message that came back from Valkey (e.g. compile error). + +##### *Examples* +```php +$valkey->eval("return 1"); // Returns an integer: 1 +$valkey->eval("return {1,2,3}"); // Returns [1,2,3] +$valkey->del('mylist'); +$valkey->rpush('mylist','a'); +$valkey->rpush('mylist','b'); +$valkey->rpush('mylist','c'); +// Nested response: [1,2,3,['a','b','c']]; +$valkey->eval("return {1,2,3,redis.call('lrange','mylist',0,-1)}"); +``` + +### evalSha +----- +_**Description**_: Evaluate a LUA script serverside, from the SHA1 hash of the script instead of the script itself. + +In order to run this command Valkey will have to have already loaded the script, +either by running it or via the SCRIPT LOAD command. + +##### *Parameters* +*script_sha* string. The sha1 encoded hash of the script you want to run. +*args* array, optional. Arguments to pass to the LUA script. +*num_keys* int, optional. The number of arguments that should go into the KEYS array, vs. the ARGV array when Valkey spins the script + +##### *Return value* +Mixed. See EVAL + +##### *Examples* +```php +$script = 'return 1'; +$sha = $valkey->script('load', $script); +$valkey->evalSha($sha); // Returns 1 +``` + +### script +----- +_**Description**_: Execute the Valkey SCRIPT command to perform various operations on the scripting subsystem. + +##### *Usage* +```php +$valkey->script('load', $script); +$valkey->script('flush'); +$valkey->script('kill'); +$valkey->script('exists', $script1, [$script2, $script3, ...]); +``` + +##### *Return value* +* SCRIPT LOAD will return the SHA1 hash of the passed script on success, and FALSE on failure. +* SCRIPT FLUSH should always return TRUE +* SCRIPT KILL will return true if a script was able to be killed and false if not +* SCRIPT EXISTS will return an array with TRUE or FALSE for each passed script + +### client +----- +_**Description**_: Issue the CLIENT command with various arguments. + +The Valkey CLIENT command can be used in four ways. +* CLIENT LIST +* CLIENT GETNAME +* CLIENT SETNAME [name] +* CLIENT KILL [ip:port] + +##### *Usage* +```php +$valkey->client('list'); // Get a list of clients +$valkey->client('getname'); // Get the name of the current connection +$valkey->client('setname', 'somename'); // Set the name of the current connection +$valkey->client('kill', ); // Kill the process at ip:port +``` + +##### *Return value* +This will vary depending on which client command was executed. + +* CLIENT LIST will return an array of arrays with client information. +* CLIENT GETNAME will return the client name or false if none has been set +* CLIENT SETNAME will return true if it can be set and false if not +* CLIENT KILL will return true if the client can be killed, and false if not + +Note: valkey-php will attempt to reconnect so you can actually kill your own connection +but may not notice losing it! +### getLastError +----- +_**Description**_: The last error message (if any) + +##### *Parameters* +*none* + +##### *Return value* +A string with the last returned script based error message, or NULL if there is no error + +##### *Examples* +```php +$valkey->eval('this-is-not-lua'); +$err = $valkey->getLastError(); +// "ERR Error compiling script (new function): user_script:1: '=' expected near '-'" +``` + +### clearLastError +----- +_**Description**_: Clear the last error message + +##### *Parameters* +*none* + +##### *Return value* +*BOOL* TRUE + +##### *Examples* +```php +$valkey->set('x', 'a'); +$valkey->incr('x'); +$err = $valkey->getLastError(); +// "ERR value is not an integer or out of range" +$valkey->clearLastError(); +$err = $valkey->getLastError(); +// NULL +``` + +### _prefix +----- +_**Description**_: A utility method to prefix the value with the prefix setting for valkey-php. + +##### *Parameters* +*value* string. The value you wish to prefix + +##### *Return value* +If a prefix is set up, the value now prefixed. If there is no prefix, the value will be returned unchanged. + +##### *Examples* +```php +$valkey->setOption(Valkey::OPT_PREFIX, 'my-prefix:'); +$valkey->_prefix('my-value'); // Will return 'my-prefix:my-value' +``` + +### _serialize +----- +_**Description**_: A utility method to serialize values manually. + +This method allows you to serialize a value with whatever serializer is configured, manually. +This can be useful for serialization/unserialization of data going in and out of EVAL commands +as valkey-php can't automatically do this itself. Note that if no serializer is set, valkey-php +will change Array values to 'Array', and Objects to 'Object'. + +##### *Parameters* +*value*: Mixed. The value to be serialized + +##### *Examples* +```php +$valkey->setOption(Valkey::OPT_SERIALIZER, Valkey::SERIALIZER_NONE); +$valkey->_serialize("foo"); // returns "foo" +$valkey->_serialize([]); // Returns "Array" +$valkey->_serialize(new stdClass()); // Returns "Object" + +$valkey->setOption(Valkey::OPT_SERIALIZER, Valkey::SERIALIZER_PHP); +$valkey->_serialize("foo"); // Returns 's:3:"foo";' +``` + +### _unserialize +----- +_**Description**_: A utility method to unserialize data with whatever serializer is set up. + +If there is no serializer set, the value will be returned unchanged. If there is a serializer set up, +and the data passed in is malformed, an exception will be thrown. This can be useful if valkey-php is +serializing values, and you return something from redis in a LUA script that is serialized. + +##### *Parameters* +*value* string. The value to be unserialized + +##### *Examples* +```php +$valkey->setOption(Valkey::OPT_SERIALIZER, Valkey::SERIALIZER_PHP); +$valkey->_unserialize('a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}'); // Will return [1,2,3] +``` diff --git a/docs/content/server.md b/docs/content/server.md new file mode 100644 index 0000000000..89ec477395 --- /dev/null +++ b/docs/content/server.md @@ -0,0 +1,269 @@ +## Server + +1. [acl](#acl) - Manage Valkey ACLs +1. [bgRewriteAOF](#bgrewriteaof) - Asynchronously rewrite the append-only file +1. [bgSave](#bgsave) - Asynchronously save the dataset to disk (in background) +1. [config](#config) - Get or Set the Valkey server configuration parameters +1. [dbSize](#dbsize) - Return the number of keys in selected database +1. [flushAll](#flushall) - Remove all keys from all databases +1. [flushDb](#flushdb) - Remove all keys from the current database +1. [info](#info) - Get information and statistics about the server +1. [lastSave](#lastsave) - Get the timestamp of the last disk save +1. [save](#save) - Synchronously save the dataset to disk (wait to complete) +1. [slaveOf](#slaveof) - Make the server a slave of another instance, or promote it to master +1. [time](#time) - Return the current server time +1. [slowLog](#slowlog) - Access the Valkey slowLog entries + +### acl +----- +_**Description**_: Execute the Valkey ACL command. + +##### *Parameters* +_variable_: Minimum of one argument for `Valkey` and two for `ValkeyCluster`. + +##### *Example* + +```php +$valkey->acl('USERS'); /* Get a list of users */ +$valkey->acl('LOG'); /* See log of Valkey' ACL subsystem */ +``` + +*Note*: In order to user the `ACL` command you must be communicating with Valkey >= 6.0 and be logged into an account that has access to administration commands such as ACL. Please reference [this tutorial](https://redis.io/topics/acl) for an overview of Valkey 6 ACLs and [the redis command reference](https://redis.io/commands) for every ACL subcommand. + +*Note*: If you are connecting to Valkey server >= 4.0.0 you can remove a key with the `unlink` method in the exact same way you would use `del`. The Valkey [unlink](https://redis.io/commands/unlink) command is non-blocking and will perform the actual deletion asynchronously. + +### bgRewriteAOF +----- +_**Description**_: Start the background rewrite of AOF (Append-Only File) + +##### *Parameters* +None. + +##### *Return value* +*BOOL*: `TRUE` in case of success, `FALSE` in case of failure. + +##### *Example* + +```php +$valkey->bgRewriteAOF(); +``` + +### bgSave +----- +_**Description**_: Asynchronously save the dataset to disk (in background) + +##### *Parameters* +None. + +##### *Return value* +*BOOL*: `TRUE` in case of success, `FALSE` in case of failure. If a save is already running, this command will fail and return `FALSE`. + +##### *Example* + +```php +$valkey->bgSave(); +``` + +### config +----- +_**Description**_: Get or Set the Valkey server configuration parameters. + +##### *Prototype* +```php +$valkey->config(string $operation, string|array|null $key = NULL, ?string $value = NULL): mixed; +``` + +##### *Return value* +*Associative array* for `GET`, key(s) -> value(s) +*bool* for `SET`, `RESETSTAT`, and `REWRITE` + +##### *Examples* +```php +$valkey->config("GET", "*max-*-entries*"); +$valkey->config("SET", ['timeout', 'loglevel']); +$valkey->config("SET", "dir", "/var/run/redis/dumps/"); +$valkey->config("SET", ['timeout' => 128, 'loglevel' => 'warning']); +$valkey->config('RESETSTAT'); +``` + +### dbSize +----- +_**Description**_: Return the number of keys in selected database. + +##### *Parameters* +None. + +##### *Return value* +*INTEGER*: DB size, in number of keys. + +##### *Example* + +```php +$count = $valkey->dbSize(); +echo "Valkey has $count keys\n"; +``` + +### flushAll +----- +_**Description**_: Remove all keys from all databases. + +##### *Parameters* +*async* (bool) requires server version 4.0.0 or greater + +##### *Return value* +*BOOL*: Always `TRUE`. + +##### *Example* + +```php +$valkey->flushAll(); +``` + +### flushDb +----- +_**Description**_: Remove all keys from the current database. + +##### *Prototype* +```php +$valkey->flushdb(?bool $sync = NULL): Valkey|bool; +``` + +##### *Return value* +*BOOL*: This command returns true on success and false on failure. + +##### *Example* + +```php +$valkey->flushDb(); +``` + +### info +----- +_**Description**_: Get information and statistics about the server + +Returns an associative array that provides information about the server. Passing no arguments to +INFO will call the standard REDIS INFO command, which returns information such as the following: + +* redis_version +* arch_bits +* uptime_in_seconds +* uptime_in_days +* connected_clients +* connected_slaves +* used_memory +* changes_since_last_save +* bgsave_in_progress +* last_save_time +* total_connections_received +* total_commands_processed +* role + +You can pass a variety of options to INFO ([per the Valkey documentation](http://redis.io/commands/info)), +which will modify what is returned. + +##### *Parameters* +*option*: The option to provide redis (e.g. "COMMANDSTATS", "CPU") + +##### *Example* + +```php +$valkey->info(); /* standard redis INFO command */ +$valkey->info("COMMANDSTATS"); /* Information on the commands that have been run (>=2.6 only) +$valkey->info("CPU"); /* just CPU information from Valkey INFO */ +``` + +### lastSave +----- +_**Description**_: Returns the timestamp of the last disk save. + +##### *Parameters* +None. + +##### *Return value* +*INT*: timestamp. + +##### *Example* + +```php +$valkey->lastSave(); +``` + +### save +----- +_**Description**_: Synchronously save the dataset to disk (wait to complete) + +##### *Parameters* +None. + +##### *Return value* +*BOOL*: `TRUE` in case of success, `FALSE` in case of failure. If a save is already running, this command will fail and return `FALSE`. + +##### *Example* + +```php +$valkey->save(); +``` + +### slaveOf +----- +_**Description**_: Changes the slave status + +##### *Parameters* +Either host (string) and port (int), or no parameter to stop being a slave. + +##### *Return value* +*BOOL*: `TRUE` in case of success, `FALSE` in case of failure. + +##### *Example* + +```php +$valkey->slaveOf('10.0.1.7', 6379); +/* ... */ +$valkey->slaveOf(); +``` + +### time +----- +_**Description**_: Return the current server time. + +##### *Parameters* +(none) + +##### *Return value* +If successful, the time will come back as an associative array with element zero being +the unix timestamp, and element one being microseconds. + +##### *Examples* +```php +$valkey->time(); +``` + +### slowLog +----- +_**Description**_: Access the Valkey slowLog + +##### *Parameters* +*Operation* (string): This can be either `GET`, `LEN`, or `RESET` +*Length* (integer), optional: If executing a `SLOWLOG GET` command, you can pass an optional length. +##### + +##### *Return value* +The return value of SLOWLOG will depend on which operation was performed. +SLOWLOG GET: Array of slowLog entries, as provided by Valkey +SLOGLOG LEN: Integer, the length of the slowLog +SLOWLOG RESET: Boolean, depending on success +##### + +##### *Examples* +```php +// Get ten slowLog entries +$valkey->slowLog('get', 10); +// Get the default number of slowLog entries + +$valkey->slowLog('get'); +// Reset our slowLog +$valkey->slowLog('reset'); + +// Retrieve slowLog length +$valkey->slowLog('len'); +``` \ No newline at end of file diff --git a/docs/content/sets.md b/docs/content/sets.md index e69de29bb2..ccbce64775 100644 --- a/docs/content/sets.md +++ b/docs/content/sets.md @@ -0,0 +1,533 @@ +## Sets + +|Command |Description |Supported |Tested |Class/Trait |Method | +|--- |--- |:-: |:-: |--- |--- | +|[sAdd](#sAdd) |Add one or more members to a set. |:white\_check\_mark: |:white\_check\_mark: |Sets |sAdd | +|[sCard](#sCard) |Get the number of members in a set. |:white\_check\_mark: |:white\_check\_mark: |Sets |sCard | +|[sSize](#sSize) |Get the number of members in a set. |:white\_check\_mark: |:white\_check\_mark: |Sets |sSize | +|[sDiff](#sDiff) |Subtract multiple sets. |:white\_check\_mark: |:white\_check\_mark: |Sets |sDiff | +|[sDiffStore](#sDiffStore) |Subtract multiple sets and store the resulting set in a key. |:white\_check\_mark: |:white\_check\_mark: |Sets |sDiffStore | +|[sInter](#sInter) |Intersect multiple sets. |:white\_check\_mark: |:white\_check\_mark: |Sets |sInter | +|[sInterStore](#sInterStore)|Intersect multiple sets and store the resulting set in a key. |:white\_check\_mark: |:white\_check\_mark: |Sets |sInterStore | +|[sIsMember](#sIsMember) |Determine if a given value is a member of a set. |:white\_check\_mark: |:white\_check\_mark: |Sets |sIsMember | +|[sContains](#sContains) |Determine if a given value is a member of a set. |:white\_check\_mark: |:white\_check\_mark: |Sets |sContains | +|[sMembers](#sMembers) |Get all the members in a set. |:white\_check\_mark: |:white\_check\_mark: |Sets |sMembers | +|[sGetMembers](#sGetMembers)|Get all the members in a set. |:white\_check\_mark: |:white\_check\_mark: |Sets |sGetMembers | +|[sMove](#sMove) |Move a member from one set to another. |:white\_check\_mark: |:white\_check\_mark: |Sets |sMove | +|[sPop](#sPop) |Remove and return one or more members of a set at random. |:white\_check\_mark: |:white\_check\_mark: |Sets |sPop | +|[sRandMember](#sRandMember)|Get one or multiple random members from a set. |:white\_check\_mark: |:white\_check\_mark: |Sets |sRandMember | +|[sRem](#sRem) |Remove one or more members from a set. |:white\_check\_mark: |:white\_check\_mark: |Sets |sRem | +|[sRemove](#sRemove) |Remove one or more members from a set. |:white\_check\_mark: |:white\_check\_mark: |Sets |sRemove | +|[sUnion](#sUnion) |Add multiple sets. |:white\_check\_mark: |:white\_check\_mark: |Sets |sUnion | +|[sUnionStore](#sUnionStore)|Add multiple sets and store the resulting set in a key. |:white\_check\_mark: |:white\_check\_mark: |Sets |sUnionStore | +|[sScan](#sScan) |Scan a set for members. |:white\_check\_mark: |:white\_check\_mark: |Sets |sScan | + +SADD Adds one or more members to a set. Creates the key if it doesn't exist. +SCARD Returns the number of members in a set. +SDIFF Returns the difference of multiple sets. +SDIFFSTORE Stores the difference of multiple sets in a key. +SINTER Returns the intersect of multiple sets. +SINTERCARD Returns the number of members of the intersect of multiple sets. +SINTERSTORE Stores the intersect of multiple sets in a key. +SISMEMBER Determines whether a member belongs to a set. +SMEMBERS Returns all members of a set. +SMISMEMBER Determines whether multiple members belong to a set. +SMOVE Moves a member from one set to another. +SPOP Returns one or more random members from a set after removing them. Deletes the set if the last member was popped. +SRANDMEMBER Get one or multiple random members from a set +SREM Removes one or more members from a set. Deletes the set if the last member was removed. +SSCAN Iterates over members of a set. +SUNION Returns the union of multiple sets. +SUNIONSTORE Stores the union of multiple sets in a key. + +* [sAdd](#sadd) - Add one or more members to a set +* [sCard](#scard) - Get the number of members in a set +* [sDiff](#sdiff) - Subtract multiple sets +* [sDiffStore](#sdiffstore) - Subtract multiple sets and store the resulting set in a key +* [sInter](#sinter) - Intersect multiple sets +* [sInterStore](#sinterstore) - Intersect multiple sets and store the resulting set in a key +* [sIsMember](#sismember) - Determine if a given value is a member of a set +* [sMembers](#smembers) - Get all the members in a set +* [sMove](#smove) - Move a member from one set to another +* [sPop](#spop) - Remove and return one or more members of a set at random +* [sRandMember](#srandmember) - Get one or multiple random members from a set +* [sRem](#srem) - Remove one or more members from a set +* [sUnion](#sunion) - Add multiple sets +* [sUnionStore](#sunionstore) - Add multiple sets and store the resulting set in a key +* [sScan](#sscan) - Scan a set for members + +## Usage + +```php +$valkey = new Valkey(); +$valkey->connect('127.0.0.1', 6379); +$valkey->sAdd('key1' , 'member1'); +$valkey->sAdd('key1' , 'member2'); +$valkey->sAdd('key1' , 'member3'); /* 'key1' => {'member1', 'member2', 'member3'}*/ +$valkey->sCard('key1'); /* 3 */ +$valkey->sIsMember('key1', 'member1'); /* TRUE */ +$valkey->sIsMember('key1', 'memberX'); /* FALSE */ +``` + +### sAdd +----- +_**Description**_: Adds a value to the set value stored at key. +##### *Parameters* +*key* +*value* + +##### *Return value* +*LONG* the number of elements added to the set. +##### *Example* + +```php +$valkey->sAdd('key1' , 'member1'); /* 1, 'key1' => {'member1'} */ +$valkey->sAdd('key1' , 'member2', 'member3'); /* 2, 'key1' => {'member1', 'member2', 'member3'}*/ +$valkey->sAdd('key1' , 'member2'); /* 0, 'key1' => {'member1', 'member2', 'member3'}*/ +``` + +### sCard +----- +_**Description**_: Returns the cardinality of the set identified by key. +##### *Parameters* +*key* +##### *Return value* +*LONG* the cardinality of the set identified by key, 0 if the set doesn't exist. +##### *Example* + +```php +$valkey->sAdd('key1' , 'member1'); +$valkey->sAdd('key1' , 'member2'); +$valkey->sAdd('key1' , 'member3'); /* 'key1' => {'member1', 'member2', 'member3'}*/ +$valkey->sCard('key1'); /* 3 */ +$valkey->sCard('keyX'); /* 0 */ +``` + +### sDiff +----- +_**Description**_: Performs the difference between N sets and returns it. + +##### *Parameters* +*Keys*: key1, key2, ... , keyN: Any number of keys corresponding to sets in redis. + +##### *Return value* +*Array of strings*: The difference of the first set will all the others. + +##### *Example* + +```php +$valkey->del('s0', 's1', 's2'); + +$valkey->sAdd('s0', '1'); +$valkey->sAdd('s0', '2'); +$valkey->sAdd('s0', '3'); +$valkey->sAdd('s0', '4'); + +$valkey->sAdd('s1', '1'); +$valkey->sAdd('s2', '3'); + +var_dump($valkey->sDiff('s0', 's1', 's2')); +``` +Return value: all elements of s0 that are neither in s1 nor in s2. +``` +array(2) { + [0]=> + string(1) "4" + [1]=> + string(1) "2" +} +``` + +### sDiffStore +----- +_**Description**_: Performs the same action as sDiff, but stores the result in the first key +##### *Parameters* +*Key*: dstkey, the key to store the diff into. + +*Keys*: key1, key2, ... , keyN: Any number of keys corresponding to sets in redis +##### *Return value* +*INTEGER*: The cardinality of the resulting set, or `FALSE` in case of a missing key. + +##### *Example* + +```php +$valkey->del('s0', 's1', 's2'); + +$valkey->sAdd('s0', '1'); +$valkey->sAdd('s0', '2'); +$valkey->sAdd('s0', '3'); +$valkey->sAdd('s0', '4'); + +$valkey->sAdd('s1', '1'); +$valkey->sAdd('s2', '3'); + +var_dump($valkey->sDiffStore('dst', 's0', 's1', 's2')); +var_dump($valkey->sMembers('dst')); +``` +Return value: the number of elements of s0 that are neither in s1 nor in s2. +``` +int(2) +array(2) { + [0]=> + string(1) "4" + [1]=> + string(1) "2" +} +``` + +### sInter +----- +_**Description**_: Returns the members of a set resulting from the intersection of all the sets held at the specified keys. + +If just a single key is specified, then this command produces the members of this set. If one of the keys +is missing, `FALSE` is returned. + +##### *Parameters* + +key1, key2, keyN: keys identifying the different sets on which we will apply the intersection. + +##### *Return value* + +Array, contain the result of the intersection between those keys. If the intersection between the different sets is empty, the return value will be empty array. + +##### *Examples* +```php +$valkey->sAdd('key1', 'val1'); +$valkey->sAdd('key1', 'val2'); +$valkey->sAdd('key1', 'val3'); +$valkey->sAdd('key1', 'val4'); + +$valkey->sAdd('key2', 'val3'); +$valkey->sAdd('key2', 'val4'); + +$valkey->sAdd('key3', 'val3'); +$valkey->sAdd('key3', 'val4'); + +var_dump($valkey->sInter('key1', 'key2', 'key3')); +``` + +Output: + +``` +array(2) { + [0]=> + string(4) "val4" + [1]=> + string(4) "val3" +} +``` + +### sInterStore +----- +_**Description**_: Performs a sInter command and stores the result in a new set. +##### *Parameters* +*Key*: dstkey, the key to store the diff into. + +*Keys*: key1, key2... keyN. key1..keyN are intersected as in sInter. + +##### *Return value* +*INTEGER*: The cardinality of the resulting set, or `FALSE` in case of a missing key. + +##### *Example* + +```php +$valkey->sAdd('key1', 'val1'); +$valkey->sAdd('key1', 'val2'); +$valkey->sAdd('key1', 'val3'); +$valkey->sAdd('key1', 'val4'); + +$valkey->sAdd('key2', 'val3'); +$valkey->sAdd('key2', 'val4'); + +$valkey->sAdd('key3', 'val3'); +$valkey->sAdd('key3', 'val4'); + +var_dump($valkey->sInterStore('output', 'key1', 'key2', 'key3')); +var_dump($valkey->sMembers('output')); +``` + +Output: + +``` +int(2) + +array(2) { + [0]=> + string(4) "val4" + [1]=> + string(4) "val3" +} +``` + +### sIsMember +----- +_**Description**_: Checks if `value` is a member of the set stored at the key `key`. +##### *Parameters* +*key* +*value* + +##### *Return value* +*BOOL* `TRUE` if `value` is a member of the set at key `key`, `FALSE` otherwise. +##### *Example* + +```php +$valkey->sAdd('key1' , 'member1'); +$valkey->sAdd('key1' , 'member2'); +$valkey->sAdd('key1' , 'member3'); /* 'key1' => {'member1', 'member2', 'member3'}*/ + +$valkey->sIsMember('key1', 'member1'); /* TRUE */ +$valkey->sIsMember('key1', 'memberX'); /* FALSE */ +``` + +### sMembers +----- +_**Description**_: Returns the contents of a set. + +##### *Parameters* +*Key*: key + +##### *Return value* +An array of elements, the contents of the set. + +##### *Example* + +```php +$valkey->del('s'); +$valkey->sAdd('s', 'a'); +$valkey->sAdd('s', 'b'); +$valkey->sAdd('s', 'a'); +$valkey->sAdd('s', 'c'); +var_dump($valkey->sMembers('s')); +``` + +Output: +``` +array(3) { + [0]=> + string(1) "c" + [1]=> + string(1) "a" + [2]=> + string(1) "b" +} +``` +The order is random and corresponds to redis' own internal representation of the set structure. + +### sMove +----- +_**Description**_: Moves the specified member from the set at srcKey to the set at dstKey. +##### *Parameters* +*srcKey* +*dstKey* +*member* +##### *Return value* +*BOOL* If the operation is successful, return `TRUE`. If the srcKey and/or dstKey didn't exist, and/or the member didn't exist in srcKey, `FALSE` is returned. +##### *Example* + +```php +$valkey->sAdd('key1' , 'member11'); +$valkey->sAdd('key1' , 'member12'); +$valkey->sAdd('key1' , 'member13'); /* 'key1' => {'member11', 'member12', 'member13'}*/ +$valkey->sAdd('key2' , 'member21'); +$valkey->sAdd('key2' , 'member22'); /* 'key2' => {'member21', 'member22'}*/ +$valkey->sMove('key1', 'key2', 'member13'); /* 'key1' => {'member11', 'member12'} */ + /* 'key2' => {'member21', 'member22', 'member13'} */ + +``` + +### sPop +----- +_**Description**_: Removes and returns a random element from the set value at Key. +##### *Parameters* +*key* +*count*: Integer, optional +##### *Return value (without count argument)* +*String* "popped" value +*Bool* `FALSE` if set identified by key is empty or doesn't exist. +##### *Return value (with count argument)* +*Array*: Member(s) returned or an empty array if the set doesn't exist +*Bool*: `FALSE` on error if the key is not a set +##### *Example* + +```php +$valkey->sAdd('key1' , 'member1'); +$valkey->sAdd('key1' , 'member2'); +$valkey->sAdd('key1' , 'member3'); /* 'key1' => {'member3', 'member1', 'member2'}*/ +$valkey->sPop('key1'); /* 'member1', 'key1' => {'member3', 'member2'} */ +$valkey->sPop('key1'); /* 'member3', 'key1' => {'member2'} */ + +/* With count */ +$valkey->sAdd('key2', 'member1', 'member2', 'member3'); +$valkey->sPop('key2', 3); /* Will return all members but in no particular order */ +``` + +### sRandMember +----- +_**Description**_: Returns a random element from the set value at Key, without removing it. +##### *Parameters* +*key* +*count* (Integer, optional) +##### *Return value* +If no count is provided, a random *String* value from the set will be returned. If a count +is provided, an array of values from the set will be returned. Read about the different +ways to use the count here: [SRANDMEMBER](http://redis.io/commands/srandmember) +*Bool* `FALSE` if set identified by key is empty or doesn't exist. +##### *Example* + +```php +$valkey->sAdd('key1' , 'member1'); +$valkey->sAdd('key1' , 'member2'); +$valkey->sAdd('key1' , 'member3'); /* 'key1' => {'member3', 'member1', 'member2'}*/ + +// No count +$valkey->sRandMember('key1'); /* 'member1', 'key1' => {'member3', 'member1', 'member2'} */ +$valkey->sRandMember('key1'); /* 'member3', 'key1' => {'member3', 'member1', 'member2'} */ + +// With a count +$valkey->sRandMember('key1', 3); // Will return an array with all members from the set +$valkey->sRandMember('key1', 2); // Will an array with 2 members of the set +$valkey->sRandMember('key1', -100); // Will return an array of 100 elements, picked from our set (with dups) +$valkey->sRandMember('empty-set', 100); // Will return an empty array +$valkey->sRandMember('not-a-set', 100); // Will return FALSE +``` + +### sRem +----- +_**Description**_: Removes the specified member from the set value stored at key. +##### *Parameters* +*key* +*member* +##### *Return value* +*LONG* The number of elements removed from the set. +##### *Example* + +```php +$valkey->sAdd('key1' , 'member1'); +$valkey->sAdd('key1' , 'member2'); +$valkey->sAdd('key1' , 'member3'); /* 'key1' => {'member1', 'member2', 'member3'}*/ +$valkey->sRem('key1', 'member2', 'member3'); /*return 2. 'key1' => {'member1'} */ +``` + +### sUnion +----- +_**Description**_: Performs the union between N sets and returns it. + +##### *Parameters* +*Keys*: key1, key2, ... , keyN: Any number of keys corresponding to sets in redis. + +##### *Return value* +*Array of strings*: The union of all these sets. + +**Note:** `sUnion` can also take a single array with keys (see example below). + +##### *Example* + +```php +$valkey->del('s0', 's1', 's2'); + +$valkey->sAdd('s0', '1'); +$valkey->sAdd('s0', '2'); +$valkey->sAdd('s1', '3'); +$valkey->sAdd('s1', '1'); +$valkey->sAdd('s2', '3'); +$valkey->sAdd('s2', '4'); + +/* Get the union with variadic arguments */ +var_dump($valkey->sUnion('s0', 's1', 's2')); + +/* Pass a single array */ +var_dump($valkey->sUnion(['s0', 's1', 's2'])); + +``` +Return value: all elements that are either in s0 or in s1 or in s2. +``` +array(4) { + [0]=> + string(1) "3" + [1]=> + string(1) "4" + [2]=> + string(1) "1" + [3]=> + string(1) "2" +} +``` + +### sUnionStore +----- +_**Description**_: Performs the same action as sUnion, but stores the result in the first key + +##### *Parameters* +*Key*: dstkey, the key to store the diff into. + +*Keys*: key1, key2, ... , keyN: Any number of keys corresponding to sets in redis. + +##### *Return value* +*INTEGER*: The cardinality of the resulting set, or `FALSE` in case of a missing key. + +##### *Example* + +```php +$valkey->del('s0', 's1', 's2'); + +$valkey->sAdd('s0', '1'); +$valkey->sAdd('s0', '2'); +$valkey->sAdd('s1', '3'); +$valkey->sAdd('s1', '1'); +$valkey->sAdd('s2', '3'); +$valkey->sAdd('s2', '4'); + +var_dump($valkey->sUnionStore('dst', 's0', 's1', 's2')); +var_dump($valkey->sMembers('dst')); +``` +Return value: the number of elements that are either in s0 or in s1 or in s2. +``` +int(4) +array(4) { + [0]=> + string(1) "3" + [1]=> + string(1) "4" + [2]=> + string(1) "1" + [3]=> + string(1) "2" +} +``` + +### sScan +----- +_**Description**_: Scan a set for members + +##### *Parameters* +*Key*: The set to search +*iterator*: LONG (reference) to the iterator as we go +*pattern*: String, optional pattern to match against +*count*: How many members to return at a time (Valkey might return a different amount) + +##### *Return value* +*Array, boolean*: PHPValkey will return an array of keys or FALSE when we're done iterating + +##### *Example* + +```php +$it = NULL; +$valkey->setOption(Valkey::OPT_SCAN, Valkey::SCAN_RETRY); /* don't return empty results until we're done */ +while($arr_mems = $valkey->sScan('set', $it, "*pattern*")) { + foreach($arr_mems as $str_mem) { + echo "Member: $str_mem\n"; + } +} + +$it = NULL; +$valkey->setOption(Valkey::OPT_SCAN, Valkey::SCAN_NORETRY); /* return after each iteration, even if empty */ +while(($arr_mems = $valkey->sScan('set', $it, "*pattern*"))!==FALSE) { + if(count($arr_mems) > 0) { + foreach($arr_mems as $str_mem) { + echo "Member found: $str_mem\n"; + } + } else { + echo "No members in this iteration, iterator value: $it\n"; + } +} +``` \ No newline at end of file diff --git a/docs/content/sorted-sets.md b/docs/content/sorted-sets.md index e69de29bb2..cec0bd3b86 100644 --- a/docs/content/sorted-sets.md +++ b/docs/content/sorted-sets.md @@ -0,0 +1,739 @@ +# Valkey PHP - Sorted sets + +|Command |Description |Supported |Tested |Class/Trait |Method | +|--- |--- |:-: |:-: |--- |--- | +|[bzPop](#bzPop) |Block until Redis can pop the highest or lowest scoring member from one or more ZSETs. |:white\_check\_mark: |:white\_check\_mark: |SortedSets |bzPop | +|[bzPopMin](#bzPopMin) |Block until Redis can pop the lowest scoring member from one or more ZSETs. |:white\_check\_mark: |:white\_check\_mark: |SortedSets |bzPopMin | +|[bzPopMax](#bzPopMax) |Block until Redis can pop the highest scoring member from one or more ZSETs. |:white\_check\_mark: |:white\_check\_mark: |SortedSets |bzPopMax | +|[zAdd](#zAdd) |Add one or more members to a sorted set or update its score if it already exists. |:white\_check\_mark: |:white\_check\_mark: |SortedSets |zAdd | +|[zCard](#zCard) |Get the number of members in a sorted set. |:white\_check\_mark: |:white\_check\_mark: |SortedSets |zCard | +|[zSize](#zSize) |Get the number of members in a sorted set. |:white\_check\_mark: |:white\_check\_mark: |SortedSets |zSize | +|[zCount](#zCount) |Count the members in a sorted set with scores within the given values. |:white\_check\_mark: |:white\_check\_mark: |SortedSets |zCount | +|[zIncrBy](#zIncrBy) |Increment the score of a member in a sorted set. |:white\_check\_mark: |:white\_check\_mark: |SortedSets |zIncrBy | +|[zinterstore](#zinterstore) |Intersect multiple sorted sets and store the resulting sorted set in a new key. |:white\_check\_mark: |:white\_check\_mark: |SortedSets |zinterstore | +|[zInter](#zInter) |Intersect multiple sorted sets and store the resulting sorted set in a new key. |:white\_check\_mark: |:white\_check\_mark: |SortedSets |zInter | +|[zPop](#zPop) |Redis can pop the highest or lowest scoring member from one a ZSET. |:white\_check\_mark: |:white\_check\_mark: |SortedSets |zPop | +|[zRange](#zRange) |Return a range of members in a sorted set, by index. |:white\_check\_mark: |:white\_check\_mark: |SortedSets |zRange | +|[zRangeByScore](#zRangeByScore) |Return a range of members in a sorted set, by score. |:white\_check\_mark: |:white\_check\_mark: |SortedSets |zRangeByScore | +|[zRevRangeByScore](#zRevRangeByScore) |Return a range of members in a sorted set, by score. |:white\_check\_mark: |:white\_check\_mark: |SortedSets |zRevRangeByScore | +|[zRangeByLex](#zRangeByLex) |Return a lexicographical range from members that share the same score. |:white\_check\_mark: |:white\_check\_mark: |SortedSets |zRangeByLex | +|[zRank](#zRank) |Determine the index of a member in a sorted set. |:white\_check\_mark: |:white\_check\_mark: |SortedSets |zRank | +|[zRevRank](#zRevRank) |Determine the index of a member in a sorted set. |:white\_check\_mark: |:white\_check\_mark: |SortedSets |zRevRank | +|[zRem](#zRem) |Remove one or more members from a sorted set. |:white\_check\_mark: |:white\_check\_mark: |SortedSets |zRem | +|[zDelete](#zDelete) |Remove one or more members from a sorted set. |:white\_check\_mark: |:white\_check\_mark: |SortedSets |zDelete | +|[zRemove](#zRemove) |Remove one or more members from a sorted set. |:white\_check\_mark: |:white\_check\_mark: |SortedSets |zRemove | +|[zRemRangeByRank](#zRemRangeByRank) |Remove all members in a sorted set within the given indexes. |:white\_check\_mark: |:white\_check\_mark: |SortedSets |zRemRangeByRank | +|[zDeleteRangeByRank](#zDeleteRangeByRank) |Remove all members in a sorted set within the given indexes. |:white\_check\_mark: |:white\_check\_mark: |SortedSets |zDeleteRangeByRank | +|[zRemRangeByScore](#zRemRangeByScore) |Remove all members in a sorted set within the given scores. |:white\_check\_mark: |:white\_check\_mark: |SortedSets |zRemRangeByScore | +|[zDeleteRangeByScore](#zDeleteRangeByScore)|Remove all members in a sorted set within the given scores. |:white\_check\_mark: |:white\_check\_mark: |SortedSets |zDeleteRangeByScore| +|[zRemoveRangeByScore](#zRemoveRangeByScore)|Remove all members in a sorted set within the given scores. |:white\_check\_mark: |:white\_check\_mark: |SortedSets |zRemoveRangeByScore| +|[zRevRange](#zRevRange) |Return a range of members in a sorted set, by index, with scores ordered from high to low. |:white\_check\_mark: |:white\_check\_mark: |SortedSets |zRevRange | +|[zScore](#zScore) |Get the score associated with the given member in a sorted set. |:white\_check\_mark: |:white\_check\_mark: |SortedSets |zScore | +|[zunionstore](#zunionstore) |Add multiple sorted sets and store the resulting sorted set in a new key. |:white\_check\_mark: |:white\_check\_mark: |SortedSets |zunionstore | +|[zUnion](#zUnion) |Add multiple sorted sets and store the resulting sorted set in a new key. |:white\_check\_mark: |:white\_check\_mark: |SortedSets |zUnion | +|[zScan](#zScan) |Scan a sorted set for members. |:white\_check\_mark: |:white\_check\_mark: |SortedSets |zScan | + +BZMPOP Removes and returns a member by score from one or more sorted sets. Blocks until a member is available otherwise. Deletes the sorted set if the last element was popped. +BZPOPMAX Removes and returns the member with the highest score from one or more sorted sets. Blocks until a member available otherwise. Deletes the sorted set if the last element was popped. +BZPOPMIN Removes and returns the member with the lowest score from one or more sorted sets. Blocks until a member is available otherwise. Deletes the sorted set if the last element was popped. +ZADD Adds one or more members to a sorted set, or updates their scores. Creates the key if it doesn't exist. +ZCARD Returns the number of members in a sorted set. +ZCOUNT Returns the count of members in a sorted set that have scores within a range. +ZDIFF Returns the difference between multiple sorted sets. +ZDIFFSTORE Stores the difference of multiple sorted sets in a key. +ZINCRBY Increments the score of a member in a sorted set. +ZINTER Returns the intersect of multiple sorted sets. +ZINTERCARD Returns the number of members of the intersect of multiple sorted sets. +ZINTERSTORE Stores the intersect of multiple sorted sets in a key. +ZLEXCOUNT Returns the number of members in a sorted set within a lexicographical range. +ZMPOP Returns the highest- or lowest-scoring members from one or more sorted sets after removing them. Deletes the sorted set if the last member was popped. +ZMSCORE Returns the score of one or more members in a sorted set. +ZPOPMAX Returns the highest-scoring members from a sorted set after removing them. Deletes the sorted set if the last member was popped. +ZPOPMIN Returns the lowest-scoring members from a sorted set after removing them. Deletes the sorted set if the last member was popped. +ZRANDMEMBER Returns one or more random members from a sorted set. +ZRANGE Returns members in a sorted set within a range of indexes. +ZRANGEBYLEX Returns members in a sorted set within a lexicographical range. +ZRANGEBYSCORE Returns members in a sorted set within a range of scores. +ZRANGESTORE Stores a range of members from sorted set in a key. +ZRANK Returns the index of a member in a sorted set ordered by ascending scores. +ZREM Removes one or more members from a sorted set. Deletes the sorted set if all members were removed. +ZREMRANGEBYLEX Removes members in a sorted set within a lexicographical range. Deletes the sorted set if all members were removed. +ZREMRANGEBYRANK Removes members in a sorted set within a range of indexes. Deletes the sorted set if all members were removed. +ZREMRANGEBYSCORE Removes members in a sorted set within a range of scores. Deletes the sorted set if all members were removed. +ZREVRANGE Returns members in a sorted set within a range of indexes in reverse order. +ZREVRANGEBYLEX Returns members in a sorted set within a lexicographical range in reverse order. +ZREVRANGEBYSCORE Returns members in a sorted set within a range of scores in reverse order. +ZREVRANK Returns the index of a member in a sorted set ordered by descending scores. +ZSCAN Iterates over members and scores of a sorted set. +ZSCORE Returns the score of a member in a sorted set. +ZUNION Returns the union of multiple sorted sets. +ZUNIONSTORE Stores the union of multiple sorted sets in a key. + +* [bzPop](#bzpop) - Block until Valkey can pop the highest or lowest scoring member from one or more ZSETs. +* [zAdd](#zadd) - Add one or more members to a sorted set or update its score if it already exists +* [zCard](#zcard) - Get the number of members in a sorted set +* [zCount](#zcount) - Count the members in a sorted set with scores within the given values +* [zDiff](#zdiff) - Computes the difference between the first and all successive input sorted sets and return the resulting sorted set +* [zdiffstore](#zdiffstore) - Computes the difference between the first and all successive input sorted sets and stores the result in a new key +* [zIncrBy](#zincrby) - Increment the score of a member in a sorted set +* [zInter](#zinter) - Intersect multiple sorted sets and return the resulting sorted set +* [zinterstore](#zinterstore) - Intersect multiple sorted sets and store the resulting sorted set in a new key +* [zMscore](#zmscore) - Get the scores associated with the given members in a sorted set +* [zPop](#zpop) - Valkey can pop the highest or lowest scoring member from one a ZSET. +* [zRange](#zrange) - Return a range of members in a sorted set, by index +* [zRangeByScore, zRevRangeByScore](#zrangebyscore-zrevrangebyscore) - Return a range of members in a sorted set, by score +* [zRangeByLex](#zrangebylex) - Return a lexicographical range from members that share the same score +* [zRank, zRevRank](#zrank-zrevrank) - Determine the index of a member in a sorted set +* [zRem](#zrem) - Remove one or more members from a sorted set +* [zRemRangeByRank](#zremrangebyrank) - Remove all members in a sorted set within the given indexes +* [zRemRangeByScore](#zremrangebyscore) - Remove all members in a sorted set within the given scores +* [zRevRange](#zrevrange) - Return a range of members in a sorted set, by index, with scores ordered from high to low +* [zScore](#zscore) - Get the score associated with the given member in a sorted set +* [zUnion](#zunion) - Add multiple sorted sets and return the resulting sorted set +* [zunionstore](#zunionstore) - Add multiple sorted sets and store the resulting sorted set in a new key +* [zScan](#zscan) - Scan a sorted set for members + +## Usage + +```php +$valkey = new Valkey(); +$valkey->connect('127.0.0.1', 6379); +$valkey->zAdd('key', 1, 'val1'); +$valkey->zAdd('key', 0, 'val0'); +$valkey->zAdd('key', 5, 'val5'); +$valkey->zRange('key', 0, -1); // [val0, val1, val5] + +// From Valkey 3.0.2 it's possible to add options like XX, NX, CH, INCR +$valkey->zAdd('key', ['CH'], 5, 'val5', 10, 'val10', 15, 'val15'); +``` + +### bzPop +----- +_**Description**_: Block until Valkey can pop the highest or lowest scoring members from one or more ZSETs. There are two commands (`BZPOPMIN` and `BZPOPMAX` for popping the lowest and highest scoring elements respectively.) + +##### *Prototype* +```php +$valkey->bzPopMin(array $keys, int $timeout): array +$valkey->bzPopMax(array $keys, int $timeout): array + +$valkey->bzPopMin(string $key1, string $key2, ... int $timeout): array +$valkey->bzPopMax(string $key1, string $key2, ... int $timeout): array +``` + +##### *Return value* +*ARRAY:* Either an array with the key member and score of the highest or lowest element or an empty array if the timeout was reached without an element to pop. + +##### *Example* + +```php +/* Wait up to 5 seconds to pop the *lowest* scoring member from sets `zs1` and `zs2`. */ +$valkey->bzPopMin(['zs1', 'zs2'], 5); +$valkey->bzPopMin('zs1', 'zs2', 5); + +/* Wait up to 5 seconds to pop the *highest* scoring member from sets `zs1` and `zs2` */ +$valkey->bzPopMax(['zs1', 'zs2'], 5); +$valkey->bzPopMax('zs1', 'zs2', 5); +``` + +**Note:** Calling these functions with an array of keys or with a variable number of arguments is functionally identical. + +### zAdd +----- +_**Description**_: Add one or more members to a sorted set or update its score if it already exists + + +##### *Prototype* +```php +$valkey->zAdd($key, [ $options ,] $score, $value [, $score1, $value1, ...]); +``` + +##### *Parameters* +*key*: string +*options*: array (optional) +*score*: double +*value*: string +*score1*: double +*value1*: string + +##### *Return value* +*Long* 1 if the element is added. 0 otherwise. + +##### *Example* + +```php +$valkey->zAdd('key', 1, 'val1'); +$valkey->zAdd('key', 0, 'val0'); +$valkey->zAdd('key', 5, 'val5'); +$valkey->zRange('key', 0, -1); // [val0, val1, val5] + +// From Valkey 3.0.2 it's possible to add options like XX, NX, CH, INCR +$valkey->zAdd('key', ['CH'], 5, 'val5', 10, 'val10', 15, 'val15'); +``` + +### zCard +----- +_**Description**_: Returns the cardinality of an ordered set. + +##### *Parameters* +*key* + +##### *Return value* +*Long*, the set's cardinality + +##### *Example* + +```php +$valkey->zAdd('key', 0, 'val0'); +$valkey->zAdd('key', 2, 'val2'); +$valkey->zAdd('key', 10, 'val10'); +$valkey->zCard('key'); /* 3 */ +``` + +### zCount +----- +_**Description**_: Returns the *number* of elements of the sorted set stored at the specified key which have scores in the range [start,end]. Adding a parenthesis before `start` or `end` excludes it from the range. +inf and -inf are also valid limits. + +##### *Parameters* +*key* +*start*: string +*end*: string + +##### *Return value* +*LONG* the size of a corresponding zRangeByScore. + +##### *Example* + +```php +$valkey->zAdd('key', 0, 'val0'); +$valkey->zAdd('key', 2, 'val2'); +$valkey->zAdd('key', 10, 'val10'); +$valkey->zCount('key', 0, 3); /* 2, corresponding to ['val0', 'val2'] */ +``` + +### zDiff +----- +_**Description**_: Computes the difference between the first and all successive input sorted sets in the first argument. The result of the difference will be returned. + +The second argument is a set of options. It can define `WITHSCORES` so that the scores are returned as well. + +##### *Parameters* +*arrayZSetKeys* +*arrayOptions* One option is available: `withscores => TRUE`. + +##### *Return value* +*ARRAY* The result of the difference of sets. + +##### *Example* + +```php +$valkey->del('k1'); +$valkey->del('k2'); +$valkey->del('k3'); + +$valkey->zAdd('k1', 0, 'val0'); +$valkey->zAdd('k1', 1, 'val1'); +$valkey->zAdd('k1', 3, 'val3'); + +$valkey->zAdd('k2', 5, 'val1'); + +$valkey->zAdd('k3', 5, 'val0'); +$valkey->zAdd('k3', 3, 'val4'); + +$valkey->zDiff(['k1', 'k2']); /* ['val0', 'val3'] */ +$valkey->zDiff(['k2', 'k1']); /* [] */ +$valkey->zDiff(['k1', 'k2'], ['withscores' => true]); /* ['val0' => 0.0, 'val3' => 3.0] */ + +$valkey->zDiff(['k1', 'k2', 'k3']); /* ['val3'] */ +$valkey->zDiff(['k3', 'k2', 'k1']); /* ['val4'] */ +``` + +### zdiffstore +----- +_**Description**_: Computes the difference between the first and all successive input sorted sets in the second argument. The result of the difference will be stored in the sorted set defined by the first argument. + +##### *Parameters* +*keyOutput* +*arrayZSetKeys* + +##### *Return value* +*LONG* The number of values in the new sorted set. + +##### *Example* + +```php +$valkey->del('k1'); +$valkey->del('k2'); +$valkey->del('k3'); + +$valkey->zAdd('k1', 0, 'val0'); +$valkey->zAdd('k1', 1, 'val1'); +$valkey->zAdd('k1', 3, 'val3'); + +$valkey->zAdd('k2', 5, 'val1'); + +$valkey->zAdd('k3', 5, 'val0'); +$valkey->zAdd('k3', 3, 'val4'); + +$valkey->zdiffstore('ko1', ['k1', 'k2']); /* 2, 'ko1' => ['val0', 'val3'] */ +$valkey->zdiffstore('ko2', ['k2', 'k1']); /* 0, 'ko2' => [] */ + +$valkey->zdiffstore('ko3', ['k1', 'k2', 'k3']); /* 1, 'ko3' => ['val3'] */ +$valkey->zdiffstore('ko4', ['k3', 'k2', 'k1']); /* 1, 'k04' => ['val4'] */ +``` + +### zIncrBy +----- +_**Description**_: Increments the score of a member from a sorted set by a given amount. + +##### *Parameters* +*key* +*value*: (double) value that will be added to the member's score +*member* + +##### *Return value* +*DOUBLE* the new value + +##### *Examples* +```php +$valkey->del('key'); +$valkey->zIncrBy('key', 2.5, 'member1'); /* key or member1 didn't exist, so member1's score is to 0 before the increment */ + /* and now has the value 2.5 */ +$valkey->zIncrBy('key', 1, 'member1'); /* 3.5 */ +``` + +### zInter +----- +_**Description**_: Creates an intersection of sorted sets given in first argument. The result of the intersection will be returned. + +The second optional argument defines `weights` to apply to the sorted sets in input. In this case, the `weights` will be multiplied by the score of each element in the sorted set before applying the aggregation. +The third argument is a set of options. It can define the `AGGREGATE` option which specify how the results of the intersection are aggregated. It can also define `WITHSCORES` so that the scores are returned as well. + +##### *Parameters* +*arrayZSetKeys* +*arrayWeights* +*arrayOptions* Two options are available: `withscores => TRUE`, and `aggregate => $behaviour`. Either "SUM", "MIN", or "MAX" defines the behaviour to use on duplicate entries during the zinter. + +##### *Return value* +*ARRAY* The result of the intersection of sets. + +##### *Example* + +```php +$valkey->del('k1'); +$valkey->del('k2'); +$valkey->del('k3'); + +$valkey->zAdd('k1', 0, 'val0'); +$valkey->zAdd('k1', 1, 'val1'); +$valkey->zAdd('k1', 3, 'val3'); + +$valkey->zAdd('k2', 5, 'val1'); +$valkey->zAdd('k2', 3, 'val3'); + +$valkey->zinter(['k1', 'k2']); /* ['val1', 'val3'] */ +$valkey->zinter(['k1', 'k2'], [1, 1]); /* ['val1', 'val3'] */ + +/* Weighted zinter */ +$valkey->zinter(['k1', 'k2'], [1, 5], 'min'); /* ['val1', 'val3'] */ +$valkey->zinter(['k1', 'k2'], [1, 5], 'max'); /* ['val3', 'val1'] */ +``` + +### zinterstore +----- +_**Description**_: Creates an intersection of sorted sets given in second argument. The result of the intersection will be stored in the sorted set defined by the first argument. + +The third optional argument defines `weights` to apply to the sorted sets in input. In this case, the `weights` will be multiplied by the score of each element in the sorted set before applying the aggregation. +The forth argument defines the `AGGREGATE` option which specify how the results of the intersection are aggregated. + +##### *Parameters* +*keyOutput* +*arrayZSetKeys* +*arrayWeights* +*aggregateFunction* Either "SUM", "MIN", or "MAX": defines the behaviour to use on duplicate entries during the zinterstore. + +##### *Return value* +*LONG* The number of values in the new sorted set. + +##### *Example* + +```php +$valkey->del('k1'); +$valkey->del('k2'); +$valkey->del('k3'); + +$valkey->del('ko1'); +$valkey->del('ko2'); +$valkey->del('ko3'); +$valkey->del('ko4'); + +$valkey->zAdd('k1', 0, 'val0'); +$valkey->zAdd('k1', 1, 'val1'); +$valkey->zAdd('k1', 3, 'val3'); + +$valkey->zAdd('k2', 5, 'val1'); +$valkey->zAdd('k2', 3, 'val3'); + +$valkey->zinterstore('ko1', ['k1', 'k2']); /* 2, 'ko1' => ['val1', 'val3'] */ +$valkey->zinterstore('ko2', ['k1', 'k2'], [1, 1]); /* 2, 'ko2' => ['val1', 'val3'] */ + +/* Weighted zinterstore */ +$valkey->zinterstore('ko3', ['k1', 'k2'], [1, 5], 'min'); /* 2, 'ko3' => ['val1', 'val3'] */ +$valkey->zinterstore('ko4', ['k1', 'k2'], [1, 5], 'max'); /* 2, 'ko4' => ['val3', 'val1'] */ +``` + +### zMscore +----- +_**Description**_: Returns the scores of the given members in the specified sorted set. + +##### *Parameters* +*key* +*members*: member1, member2, ... , memberN: Any number of members in the specified sorted set. + +##### *Return value* +*ARRAY* or *FALSE* when the key is not found. Array entries corresponding to members that do not exist will be `false`. + +##### *Example* + +```php +$valkey->zAdd('key', 2.5, 'val2'); +$valkey->zAdd('key', 4.5, 'val4'); + +$valkey->zMscore('key', 'val2', 'val3', 'val4'); /* [2.5, false, 4.5] */ +``` + +### zPop +----- +_**Description**_: Can pop the highest or lowest scoring members from one ZSETs. There are two commands (`ZPOPMIN` and `ZPOPMAX` for popping the lowest and highest scoring elements respectively.) + +##### *Prototype* +```php +$valkey->zPopMin(string $key, int $count): array +$valkey->zPopMax(string $key, int $count): array + +$valkey->zPopMin(string $key, int $count): array +$valkey->zPopMax(string $key, int $count): array +``` + +##### *Return value* +*ARRAY:* Either an array with the key member and score of the highest or lowest element or an empty array if there is no element available. + +##### *Example* + +```php +/* Pop the *lowest* scoring member from set `zs1`. */ +$valkey->zPopMin('zs1', 5); + +/* Pop the *highest* scoring member from set `zs1`. */ +$valkey->zPopMax('zs1', 5); +``` + +### zRange +----- +_**Description**_: Returns a range of elements from the ordered set stored at the specified key, with values in the range [start, end]. + +Start and stop are interpreted as zero-based indices: +`0` the first element, `1` the second ... +`-1` the last element, `-2` the penultimate ... + +##### *Parameters* +*key* +*start*: long +*end*: long +*withscores*: bool = false + +##### *Return value* +*Array* containing the values in specified range. + +##### *Example* + +```php +$valkey->zAdd('key1', 0, 'val0'); +$valkey->zAdd('key1', 2, 'val2'); +$valkey->zAdd('key1', 10, 'val10'); +$valkey->zRange('key1', 0, -1); /* ['val0', 'val2', 'val10'] */ + +// with scores +$valkey->zRange('key1', 0, -1, true); /* ['val0' => 0, 'val2' => 2, 'val10' => 10] */ +``` + +### zRangeByScore, zRevRangeByScore +----- +_**Description**_: Returns the elements of the sorted set stored at the specified key which have scores in the range [start,end]. Adding a parenthesis before `start` or `end` excludes it from the range. +inf and -inf are also valid limits. zRevRangeByScore returns the same items in reverse order, when the `start` and `end` parameters are swapped. + +##### *Parameters* +*key* +*start*: string +*end*: string +*options*: array + +Two options are available: `withscores => TRUE`, and `limit => [$offset, $count]` + +##### *Return value* +*Array* containing the values in specified range. + +##### *Example* + +```php +$valkey->zAdd('key', 0, 'val0'); +$valkey->zAdd('key', 2, 'val2'); +$valkey->zAdd('key', 10, 'val10'); +$valkey->zRangeByScore('key', 0, 3); /* ['val0', 'val2'] */ +$valkey->zRangeByScore('key', 0, 3, ['withscores' => TRUE]); /* ['val0' => 0, 'val2' => 2] */ +$valkey->zRangeByScore('key', 0, 3, ['limit' => [1, 1]]); /* ['val2'] */ +$valkey->zRangeByScore('key', 0, 3, ['withscores' => TRUE, 'limit' => [1, 1]]); /* ['val2' => 2] */ +$valkey->zRangeByScore('key', '-inf', '+inf', ['withscores' => TRUE]); /* ['val0' => 0, 'val2' => 2, 'val10' => 10] */ +``` + +### zRangeByLex +----- +_**Description**_: Returns a lexicographical range of members in a sorted set, assuming the members have the same score. The min and max values are required to start with '(' (exclusive), '[' (inclusive), or be exactly the values '-' (negative inf) or '+' (positive inf). The command must be called with either three *or* five arguments or will return FALSE. + +##### *Parameters* +*key*: The ZSET you wish to run against +*min*: The minimum alphanumeric value you wish to get +*max*: The maximum alphanumeric value you wish to get +*offset*: Optional argument if you wish to start somewhere other than the first element. +*limit*: Optional argument if you wish to limit the number of elements returned. + +##### *Return value* +*Array* containing the values in the specified range. + +##### *Example* + +```php +foreach(['a','b','c','d','e','f','g'] as $c) + $valkey->zAdd('key',0,$c); + +$valkey->zRangeByLex('key','-','[c') /* ['a','b','c']; */ +$valkey->zRangeByLex('key','-','(c') /* ['a','b'] */ +$valkey->zRangeByLex('key','-','[c',1,2) /* ['b','c'] */ +``` + +### zRank, zRevRank +----- +_**Description**_: Returns the rank of a given member in the specified sorted set, starting at 0 for the item with the smallest score. zRevRank starts at 0 for the item with the *largest* score. + +##### *Parameters* +*key* +*member* + +##### *Return value* +*Long*, the item's rank. + +##### *Example* + +```php +$valkey->del('z'); +$valkey->zAdd('key', 1, 'one'); +$valkey->zAdd('key', 2, 'two'); +$valkey->zRank('key', 'one'); /* 0 */ +$valkey->zRank('key', 'two'); /* 1 */ +$valkey->zRevRank('key', 'one'); /* 1 */ +$valkey->zRevRank('key', 'two'); /* 0 */ +``` + +### zRem +----- +_**Description**_: Delete one or more members from a sorted set. + +##### *Prototype* +```php +$valkey->zRem($key, $member [, $member ...]); +``` + +##### *Return value* +*LONG:* The number of members deleted. + +##### *Example* + +```php +$valkey->zAdd('key', 0, 'val0', 1, 'val1', 2, 'val2'); +$valkey->zRem('key', 'val0', 'val1', 'val2'); // Returns: 3 +``` + +### zRemRangeByRank +----- +_**Description**_: Deletes the elements of the sorted set stored at the specified key which have rank in the range [start,end]. + +##### *Parameters* +*key* +*start*: LONG +*end*: LONG + +##### *Return value* +*LONG* The number of values deleted from the sorted set + +##### *Example* + +```php +$valkey->zAdd('key', 1, 'one'); +$valkey->zAdd('key', 2, 'two'); +$valkey->zAdd('key', 3, 'three'); +$valkey->zRemRangeByRank('key', 0, 1); /* 2 */ +$valkey->zRange('key', 0, -1, ['withscores' => TRUE]); /* ['three' => 3] */ +``` + +### zRemRangeByScore +----- +_**Description**_: Deletes the elements of the sorted set stored at the specified key which have scores in the range [start,end]. + +##### *Parameters* +*key* +*start*: double or "+inf" or "-inf" string +*end*: double or "+inf" or "-inf" string + +##### *Return value* +*LONG* The number of values deleted from the sorted set + +##### *Example* + +```php +$valkey->zAdd('key', 0, 'val0'); +$valkey->zAdd('key', 2, 'val2'); +$valkey->zAdd('key', 10, 'val10'); +$valkey->zRemRangeByScore('key', 0, 3); /* 2 */ +``` + +### zRevRange +----- +_**Description**_: Returns the elements of the sorted set stored at the specified key in the range [start, end] in reverse order. start and stop are interpreted as zero-based indices: +`0` the first element, `1` the second ... +`-1` the last element, `-2` the penultimate ... + +##### *Parameters* +*key* +*start*: long +*end*: long +*withscores*: bool = false + +##### *Return value* +*Array* containing the values in specified range. + +##### *Example* + +```php +$valkey->zAdd('key', 0, 'val0'); +$valkey->zAdd('key', 2, 'val2'); +$valkey->zAdd('key', 10, 'val10'); +$valkey->zRevRange('key', 0, -1); /* ['val10', 'val2', 'val0'] */ + +// with scores +$valkey->zRevRange('key', 0, -1, true); /* ['val10' => 10, 'val2' => 2, 'val0' => 0] */ +``` + +### zScore +----- +_**Description**_: Returns the score of a given member in the specified sorted set. + +##### *Parameters* +*key* +*member* + +##### *Return value* +*Double* or *FALSE* when the value is not found + +##### *Example* + +```php +$valkey->zAdd('key', 2.5, 'val2'); +$valkey->zScore('key', 'val2'); /* 2.5 */ +``` + +### zUnion +----- +_**Description**_: Creates an union of sorted sets given in first argument. The result of the union will be returned. + +The second optional argument defines `weights` to apply to the sorted sets in input. In this case, the `weights` will be multiplied by the score of each element in the sorted set before applying the aggregation. +The third argument is a set of options. It can define the `AGGREGATE` option which specify how the results of the intersection are aggregated. It can also define `WITHSCORES` so that the scores are returned as well. + +##### *Parameters* +*arrayZSetKeys* +*arrayWeights* +*arrayOptions* Two options are available: `withscores => TRUE`, and `aggregate => $behaviour`. Either "SUM", "MIN", or "MAX" defines the behaviour to use on duplicate entries during the zunion. + +##### *Return value* +*ARRAY* The result of the union of sets. + +##### *Example* + +```php +$valkey->del('k1'); +$valkey->del('k2'); +$valkey->del('k3'); + +$valkey->zAdd('k1', 0, 'val0'); +$valkey->zAdd('k1', 1, 'val1'); + +$valkey->zAdd('k2', 2, 'val2'); +$valkey->zAdd('k2', 3, 'val3'); + +$valkey->zunion(['k1', 'k2']); /* ['val0', 'val1', 'val2', 'val3'] */ + +/* Weighted zunion */ +$valkey->zunion(['k1', 'k2'], [1, 1]); /* ['val0', 'val1', 'val2', 'val3'] */ +$valkey->zunion(['k1', 'k2'], [5, 1]); /* ['val0', 'val2', 'val3', 'val1'] */ +``` + +### zunionstore +----- +_**Description**_: Creates an union of sorted sets given in second argument. The result of the union will be stored in the sorted set defined by the first argument. + +The third optional argument defines `weights` to apply to the sorted sets in input. In this case, the `weights` will be multiplied by the score of each element in the sorted set before applying the aggregation. +The forth argument defines the `AGGREGATE` option which specify how the results of the union are aggregated. + +##### *Parameters* +*keyOutput* +*arrayZSetKeys* +*arrayWeights* +*aggregateFunction* Either "SUM", "MIN", or "MAX": defines the behaviour to use on duplicate entries during the zunionstore. + +##### *Return value* +*LONG* The number of values in the new sorted set. + +##### *Example* + +```php +$valkey->del('k1'); +$valkey->del('k2'); +$valkey->del('k3'); +$valkey->del('ko1'); +$valkey->del('ko2'); +$valkey->del('ko3'); + +$valkey->zAdd('k1', 0, 'val0'); +$valkey->zAdd('k1', 1, 'val1'); + +$valkey->zAdd('k2', 2, 'val2'); +$valkey->zAdd('k2', 3, 'val3'); + +$valkey->zunionstore('ko1', ['k1', 'k2']); /* 4, 'ko1' => ['val0', 'val1', 'val2', 'val3'] */ + +/* Weighted zunionstore */ +$valkey->zunionstore('ko2', ['k1', 'k2'], [1, 1]); /* 4, 'ko2' => ['val0', 'val1', 'val2', 'val3'] */ +$valkey->zunionstore('ko3', ['k1', 'k2'], [5, 1]); /* 4, 'ko3' => ['val0', 'val2', 'val3', 'val1'] */ +``` + +### zScan +----- +_**Description**_: Scan a sorted set for members, with optional pattern and count + +##### *Parameters* +*key*: String, the set to scan +*iterator*: Long (reference), initialized to NULL +*pattern*: String (optional), the pattern to match +*count*: How many keys to return per iteration (Valkey might return a different number) + +##### *Return value* +*Array, boolean* PHPValkey will return matching keys from Valkey, or FALSE when iteration is complete + +##### *Example* + +```php +$it = NULL; +$valkey->setOption(Valkey::OPT_SCAN, Valkey::SCAN_RETRY); +while($arr_matches = $valkey->zScan('zset', $it, '*pattern*')) { + foreach($arr_matches as $str_mem => $f_score) { + echo "Key: $str_mem, Score: $f_score\n"; + } +} +``` diff --git a/docs/content/streams.md b/docs/content/streams.md index e69de29bb2..1df316da9b 100644 --- a/docs/content/streams.md +++ b/docs/content/streams.md @@ -0,0 +1,409 @@ +# Valkey PHP - Streams + +|Command |Description |Supported |Tested |Class/Trait |Method | +|--- |--- |:-: |:-: |--- |--- | +|[xAck](#xAck) |Acknowledge one or more pending messages. |:white\_check\_mark: |:white\_check\_mark: |Streams |xAck | +|[xAdd](#xAdd) |Add a message to a stream. |:white\_check\_mark: |:white\_check\_mark: |Streams |xAdd | +|[xClaim](#xClaim) |Acquire ownership of a pending message. |:white\_check\_mark: |:white\_check\_mark: |Streams |xClaim | +|[xDel](#xDel) |Remove a message from a stream. |:white\_check\_mark: |:white\_check\_mark: |Streams |xDel | +|[xGroup](#xGroup) |Manage consumer groups. |:white\_check\_mark: |:white\_check\_mark: |Streams |xGroup | +|[xInfo](#xInfo) |Get information about a stream. |:white\_check\_mark: |:white\_check\_mark: |Streams |xInfo | +|[xLen](#xLen) |Get the length of a stream. |:white\_check\_mark: |:white\_check\_mark: |Streams |xLen | +|[xPending](#xPending) |Inspect pending messages in a stream. |:white\_check\_mark: |:white\_check\_mark: |Streams |xPending | +|[xRange](#xRange) |Query a range of messages from a stream. |:white\_check\_mark: |:white\_check\_mark: |Streams |xRange | +|[xRead](#xRead) |Read message(s) from a stream. |:white\_check\_mark: |:white\_check\_mark: |Streams |xRead | +|[xReadGroup](#xReadGroup) |Read stream messages with a group and consumer.|:white\_check\_mark: |:white\_check\_mark: |Streams |xReadGroup | +|[xRevRange](#xRevRange) |Query one or more messages from end to start. |:white\_check\_mark: |:white\_check\_mark: |Streams |xRevRange | +|[xTrim](#xTrim) |Trim a stream's size. |:white\_check\_mark: |:white\_check\_mark: |Streams |xTrim | + +- XACK Returns the number of messages that were successfully acknowledged by the consumer group member of a stream. +- XADD Appends a new message to a stream. Creates the key if it doesn't exist. +- XAUTOCLAIM Changes, or acquires, ownership of messages in a consumer group, as if the messages were delivered to as consumer group member. +- XCLAIM Changes, or acquires, ownership of a message in a consumer group, as if the message was delivered a consumer group member. +- XDEL Returns the number of messages after removing them from a stream. +- XGROUP A container for consumer groups commands. +- XGROUP CREATE Creates a consumer group. +- XGROUP CREATECONSUMER Creates a consumer in a consumer group. +- XGROUP DELCONSUMER Deletes a consumer from a consumer group. +- XGROUP DESTROY Destroys a consumer group. +- XGROUP HELP Returns helpful text about the different subcommands. +- XGROUP SETID Sets the last-delivered ID of a consumer group. +- XINFO A container for stream introspection commands. +- XINFO CONSUMERS Returns a list of the consumers in a consumer group. +- XINFO GROUPS Returns a list of the consumer groups of a stream. +- XINFO HELP Returns helpful text about the different subcommands. +- XINFO STREAM Returns information about a stream. +- XLEN Return the number of messages in a stream. +- XPENDING Returns the information and entries from a stream consumer group's pending entries list. +- XRANGE Returns the messages from a stream within a range of IDs. +- XREAD Returns messages from multiple streams with IDs greater than the ones requested. Blocks until a message is available otherwise. +- XREADGROUP Returns new or historical messages from a stream for a consumer in a group. Blocks until a message is available otherwise. +- XREVRANGE Returns the messages from a stream within a range of IDs in reverse order. +- XSETID An internal command for replicating stream values. +- XTRIM Deletes messages from the beginning of a stream. + +* [xAck](#xack) - Acknowledge one or more pending messages +* [xAdd](#xadd) - Add a message to a stream +* [xClaim](#xclaim) - Acquire ownership of a pending message +* [xDel](#xdel) - Remove a message from a stream +* [xGroup](#xgroup) - Manage consumer groups +* [xInfo](#xinfo) - Get information about a stream +* [xLen](#xlen) - Get the length of a stream +* [xPending](#xpending) - Inspect pending messages in a stream +* [xRange](#xrange) - Query a range of messages from a stream +* [xRead](#xread) - Read message(s) from a stream +* [xReadGroup](#xreadgroup) - Read stream messages with a group and consumer +* [xRevRange](#xrevrange) - Query one or more messages from end to start +* [xTrim](#xtrim) - Trim a stream's size + +## Usage + +```php +$valkey = new Valkey(); +$valkey->connect('127.0.0.1', 6379); + +$obj_redis->xAdd('mystream', "*", ['field' => 'value']); +$obj_redis->xAdd('mystream', "*", ['field' => 'value'], 1000); // set max length of stream to 1000 +$obj_redis->xAdd('mystream', "*", ['field' => 'value'], 1000, true); // set max length of stream to ~1000 +$obj_redis->xAck('mystream', 'group1', ['1530063064286-0', '1530063064286-1']); + +/* Get everything in this stream */ +$obj_redis->xRange('mystream', '-', '+'); + +/* Only the first two messages */ +$obj_redis->xRange('mystream', '-', '+', 2); + +$obj_redis->xInfo('STREAM', 'mystream', 'FULL', 10); + +$obj_redis->xRead(['stream1' => '1535222584555-0', 'stream2' => '1535222584555-0']); + +$obj_redis->xDel('mystream', ['1530115304877-0', '1530115305731-0']); +``` + +### xAck +----- + +##### *Prototype* +```php +$obj_redis->xAck($stream, $group, $arr_messages); +``` + +_**Description**_: Acknowledge one or more messages on behalf of a consumer group. + +##### *Return value* +*long*: The number of messages Valkey reports as acknowledged. + +##### *Example* + +```php +$obj_redis->xAck('stream', 'group1', ['1530063064286-0', '1530063064286-1']); +``` + +### xAdd +----- + +##### *Prototype* +```php +$obj_redis->xAdd($str_key, $str_id, $arr_message[, $i_maxlen, $boo_approximate]); +``` + +_**Description**_: Add a message to a stream + +##### *Return value* +*String*: The added message ID + +##### *Example* + +```php +$obj_redis->xAdd('mystream', "*", ['field' => 'value']); +$obj_redis->xAdd('mystream', "*", ['field' => 'value'], 1000); // set max length of stream to 1000 +$obj_redis->xAdd('mystream', "*", ['field' => 'value'], 1000, true); // set max length of stream to ~1000 +``` + +### xClaim +----- + +##### *Prototype* +```php +$obj_redis->xClaim($str_key, $str_group, $str_consumer, $min_idle_time, $arr_ids, [$arr_options]); +``` + +_**Description**_: Claim ownership of one or more pending messages. + +#### *Options Array* +```php +$options = [ + /* Note: 'TIME', and 'IDLE' are mutually exclusive */ + 'IDLE' => $value, /* Set the idle time to $value ms */, + 'TIME' => $value, /* Set the idle time to now - $value */ + 'RETRYCOUNT' => $value, /* Update message retrycount to $value */ + 'FORCE', /* Claim the message(s) even if they're not pending anywhere */ + 'JUSTID', /* Instruct Valkey to only return IDs */ +]; +``` + +##### *Return value* +*Array*: Either an array of message IDs along with corresponding data, or just an array of IDs (if the 'JUSTID' option was passed). + +##### *Example* + +```php +$ids = ['1530113681011-0', '1530113681011-1', '1530113681011-2']; + +/* Without any options */ +$obj_redis->xClaim( + 'mystream', 'group1', 'myconsumer1', 0, $ids +); + +/* With options */ +$obj_redis->xClaim( + 'mystream', 'group1', 'myconsumer2', 0, $ids, + [ + 'IDLE' => time() * 1000, + 'RETRYCOUNT' => 5, + 'FORCE', + 'JUSTID' + ] +); +``` + +### xDel +----- + +##### *Prototype* +```php +$obj_redis->xDel($str_key, $arr_ids); +``` + +_**Description**_: Delete one or more messages from a stream. + +##### *Return value* +*long*: The number of messages removed + +##### *Example* + +```php +$obj_redis->xDel('mystream', ['1530115304877-0', '1530115305731-0']); +``` + +### xGroup +----- + +##### *Prototype* +```php +$obj_redis->xGroup('HELP'); +$obj_redis->xGroup('CREATE', $str_key, $str_group, $str_msg_id, [$boo_mkstream]); +$obj_redis->xGroup('SETID', $str_key, $str_group, $str_msg_id); +$obj_redis->xGroup('DESTROY', $str_key, $str_group); +$obj_redis->xGroup('DELCONSUMER', $str_key, $str_group, $str_consumer_name); +``` + +_**Description**_: This command is used in order to create, destroy, or manage consumer groups. + +##### *Return value* +*Mixed*: This command returns different types depending on the specific XGROUP command executed. + +##### *Example* + +```php +$obj_redis->xGroup('CREATE', 'mystream', 'mygroup', '0'); +$obj_redis->xGroup('CREATE', 'mystream', 'mygroup2', '0', true); /* Create stream if non-existent. */ +$obj_redis->xGroup('DESTROY', 'mystream', 'mygroup'); +``` + +### xInfo +----- + +##### *Prototype* +```php +$obj_redis->xInfo('CONSUMERS', $str_stream, $str_group); +$obj_redis->xInfo('GROUPS', $str_stream); +$obj_redis->xInfo('STREAM', $str_stream [, 'FULL' [, $i_count]]); +$obj_redis->xInfo('HELP'); +``` + +_**Description**_: Get information about a stream or consumer groups. + +##### *Return value* +*Mixed*: This command returns different types depending on which subcommand is used. + +##### *Example* + +```php +$obj_redis->xInfo('STREAM', 'mystream'); +$obj_redis->xInfo('STREAM', 'mystream', 'FULL', 10); +``` + +### xLen +----- + +##### *Prototype* +```php +$obj_redis->xLen($str_stream); +``` + +_**Description**_: Get the length of a given stream + +##### *Return value* +*Long*: The number of messages in the stream. + +##### *Example* + +```php +$obj_redis->xLen('mystream'); +``` + +### xPending +----- + +##### *Prototype* +```php +$obj_redis->xPending($str_stream, $str_group [, $str_start, $str_end, $i_count, $str_consumer]); +``` + +_**Description**_: Get information about pending messages in a given stream. + +##### *Return value* +*Array*: Information about the pending messages, in various forms depending on the specific invocation of XPENDING. + +##### *Examples* +```php +$obj_redis->xPending('mystream', 'mygroup'); +$obj_redis->xPending('mystream', 'mygroup', '-', '+', 1, 'consumer-1'); +``` + +### xRange +----- + +##### *Prototype* +```php +$obj_redis->xRange($str_stream, $str_start, $str_end [, $i_count]); +``` + +_**Description**_: Get a range of messages from a given stream. + +##### *Return value* +*Array*: The messages in the stream within the requested range. + +##### *Example* + +```php +/* Get everything in this stream */ +$obj_redis->xRange('mystream', '-', '+'); + +/* Only the first two messages */ +$obj_redis->xRange('mystream', '-', '+', 2); +``` + +### xRead +----- + +##### *Prototype* +```php +$obj_redis->xRead($arr_streams [, $i_count, $i_block]); +``` + +_**Description**_: Read data from one or more streams and only return IDs greater than sent in the command. + +##### *Return value* +*Array*: The messages in the stream newer than the IDs passed to Valkey (if any). + +##### *Example* + +```php +$obj_redis->xRead(['stream1' => '1535222584555-0', 'stream2' => '1535222584555-0']); + +/* --- Possible output --- +Array +( + [stream1] => Array + ( + [1535222584555-1] => Array + ( + [key:1] => val:1 + ) + + ) + + [stream2] => Array + ( + [1535222584555-1] => Array + ( + [key:1] => val:1 + ) + + ) + +) +*/ + +// Receive only new message ($ = last id) and wait for one new message unlimited time +$obj_redis->xRead(['stream1' => '$'], 1, 0); +``` + +### xReadGroup +----- + +##### *Prototype* +```php +$obj_redis->xReadGroup($str_group, $str_consumer, $arr_streams [, $i_count, $i_block]); +``` + +_**Description**_: This method is similar to xRead except that it supports reading messages for a specific consumer group. + +##### *Return value* +*Array*: The messages delivered to this consumer group (if any). + +##### *Examples* +```php +/* Consume messages for 'mygroup', 'consumer1' */ +$obj_redis->xReadGroup('mygroup', 'consumer1', ['s1' => 0, 's2' => 0]); + +/* Consume messages for 'mygroup', 'consumer1' which were not consumed yet by the group */ +$obj_redis->xReadGroup('mygroup', 'consumer1', ['s1' => '>', 's2' => '>']); + +/* Read a single message as 'consumer2' wait for up to a second until a message arrives. */ +$obj_redis->xReadGroup('mygroup', 'consumer2', ['s1' => 0, 's2' => 0], 1, 1000); +``` + +### xRevRange +----- + +##### *Prototype* +```php +$obj_redis->xRevRange($str_stream, $str_end, $str_start [, $i_count]); +``` + +_**Description**_: This is identical to xRange except the results come back in reverse order. Also note that Valkey reverses the order of "start" and "end". + +##### *Return value* +*Array*: The messages in the range specified. + +##### *Example* + +```php +$obj_redis->xRevRange('mystream', '+', '-'); +``` + +### xTrim +----- + +##### *Prototype* +```php +$obj_redis->xTrim($str_stream, $i_max_len [, $boo_approximate]); +``` + +_**Description**_: Trim the stream length to a given maximum. If the "approximate" flag is pasesed, Valkey will use your size as a hint but only trim trees in whole nodes (this is more efficient). + +##### *Return value* +*long*: The number of messages trimmed from the stream. + +##### *Example* + +```php +/* Trim to exactly 100 messages */ +$obj_redis->xTrim('mystream', 100); + +/* Let Valkey approximate the trimming */ +$obj_redis->xTrim('mystream', 100, true); +``` diff --git a/docs/content/strings.md b/docs/content/strings.md index e69de29bb2..c31a8d94eb 100644 --- a/docs/content/strings.md +++ b/docs/content/strings.md @@ -0,0 +1,479 @@ +# Valkey PHP - Strings + +|Command |Description |Supported |Tested |Class/Trait |Method | +|--- |--- |:-: |:-: |--- |--- | +|[append](#append) |Append a value to a key |:white\_check\_mark: |:white\_check\_mark: |Strings |append | +|[decr](#decr) |Decrement the value of a key |:white\_check\_mark: |:white\_check\_mark: |Strings |decr | +|[decrBy](#decrBy) |Decrement the value of a key |:white\_check\_mark: |:white\_check\_mark: |Strings |decrBy | +|[get](#get) |Get the value of a key |:white\_check\_mark: |:white\_check\_mark: |Strings |get | +|[getRange](#getRange) |Get a substring of the string stored at a key |:white\_check\_mark: |:white\_check\_mark: |Strings |getRange | +|[getSet](#getSet) |Set the string value of a key and return its old value |:white\_check\_mark: |:white\_check\_mark: |Strings |getSet | +|[incr](#incr) |Increment the value of a key |:white\_check\_mark: |:white\_check\_mark: |Strings |incr | +|[incrBy](#incrBy) |Increment the value of a key |:white\_check\_mark: |:white\_check\_mark: |Strings |incrBy | +|[incrByFloat](#incrByFloat) |Increment the float value of a key by the given amount |:white\_check\_mark: |:white\_check\_mark: |Strings |incrByFloat | +|[mGet](#mGet) |Get the values of all the given keys |:white\_check\_mark: |:white\_check\_mark: |Strings |mGet | +|[getMultiple](#getMultiple) |Get the values of all the given keys |:white\_check\_mark: |:white\_check\_mark: |Strings |getMultiple | +|[mSet](#mSet) |Set multiple keys to multiple values |:white\_check\_mark: |:white\_check\_mark: |Strings |mSet | +|[mSetNX](#mSetNX) |Set multiple keys to multiple values |:white\_check\_mark: |:white\_check\_mark: |Strings |mSetNX | +|[set](#set) |Set the string value of a key |:white\_check\_mark: |:white\_check\_mark: |Strings |set | +|[setEx](#setEx) |Set the value and expiration of a key |:white\_check\_mark: |:white\_check\_mark: |Strings |setEx | +|[pSetEx](#pSetEx) |Set the value and expiration of a key |:white\_check\_mark: |:white\_check\_mark: |Strings |pSetEx | +|[setNx](#setNx) |Set the value of a key, only if the key does not exist |:white\_check\_mark: |:white\_check\_mark: |Strings |setNx | +|[setRange](#setRange) |Overwrite part of a string at key starting at the specified offset |:white\_check\_mark: |:white\_check\_mark: |Strings |setRange | +|[strLen](#strLen) |Get the length of the value stored in a key |:white\_check\_mark: |:white\_check\_mark: |Strings |strLen | + +- APPEND Appends a string to the value of a key. Creates the key if it doesn't exist. +- DECR Decrements the integer value of a key by one. Uses 0 as initial value if the key doesn't exist. +- DECRBY Decrements a number from the integer value of a key. Uses 0 as initial value if the key doesn't exist. +- GET Returns the string value of a key. +- GETDEL Returns the string value of a key after deleting the key. +- GETEX Returns the string value of a key after setting its expiration time. +- GETRANGE Returns a substring of the string stored at a key. +- GETSET Returns the previous string value of a key after setting it to a new value. +- INCR Increments the integer value of a key by one. Uses 0 as initial value if the key doesn't exist. +- INCRBY Increments the integer value of a key by a number. Uses 0 as initial value if the key doesn't exist. +- INCRBYFLOAT Increment the floating point value of a key by a number. Uses 0 as initial value if the key doesn't exist. +- LCS Finds the longest common substring. +- MGET Atomically returns the string values of one or more keys. +- MSET Atomically creates or modifies the string values of one or more keys. +- MSETNX Atomically modifies the string values of one or more keys only when all keys don't exist. +- PSETEX Sets both string value and expiration time in milliseconds of a key. The key is created if it doesn't exist. +- SET Sets the string value of a key, ignoring its type. The key is created if it doesn't exist. +- SETEX Sets the string value and expiration time of a key. Creates the key if it doesn't exist. +- SETNX Set the string value of a key only when the key doesn't exist. +- SETRANGE Overwrites a part of a string value with another by an offset. Creates the key if it doesn't exist. +- STRLEN Returns the length of a string value. +- SUBSTR Returns a substring from a string value. + +## Usage + +```php +$valkey = new Valkey(); +$valkey->connect('127.0.0.1', 6379); +// Simple key -> value set +$valkey->set('key', 'value'); +// Will redirect, and actually make an SETEX call +$valkey->set('key', 'value', 10); +// Will set the key, if it doesn't exist, with a ttl of 10 seconds +$valkey->set('key:'.time(), 'value', ['nx', 'ex' => 10]); +// Will set a key, if it does exist, with a ttl of 1000 miliseconds +$valkey->set('key', 'value', ['xx', 'px' => 1000]); +$valkey->setEx('key', 10, 'value1'); +$valkey->append('key', 'value2'); /* 12 */ +$valkey->get('key'); /* 'value1value2' */ +$valkey->exists('key'); /* 1 */ +$valkey->exists('NonExistingKey'); /* 0 */ +$valkey->mset(['foo' => 'foo', 'bar' => 'bar', 'baz' => 'baz']); +$valkey->exists(['foo', 'bar', 'baz']); /* 3 */ +``` + +* [append](#append) - Append a value to a key +* [decr, decrBy](#decr-decrby) - Decrement the value of a key +* [get](#get) - Get the value of a key +* [getEx](#getex) - Get the value of a key and set its expiration +* [getRange](#getrange) - Get a substring of the string stored at a key +* [getSet](#getset) - Set the string value of a key and return its old value +* [incr, incrBy](#incr-incrby) - Increment the value of a key +* [incrByFloat](#incrbyfloat) - Increment the float value of a key by the given amount +* [mGet](#mget) - Get the values of all the given keys +* [mSet, mSetNX](#mset-msetnx) - Set multiple keys to multiple values +* [set](#set) - Set the string value of a key +* [setEx, pSetEx](#setex-psetex) - Set the value and expiration of a key +* [setNx](#setnx) - Set the value of a key, only if the key does not exist +* [setRange](#setrange) - Overwrite part of a string at key starting at the specified offset +* [strLen](#strlen) - Get the length of the value stored in a key + +----- + +## append + +----- + +_**Description**_: Append specified string to the string stored in specified key. + +#### *Parameters* + +*Key* +*Value* + +#### *Return value* + +*INTEGER*: Size of the value after the append + +#### *Example* + +```php +$valkey->set('key', 'value1'); +$valkey->append('key', 'value2'); /* 12 */ +$valkey->get('key'); /* 'value1value2' */ +``` + +## get + +----- + +_**Description**_: Get the value related to the specified key + +#### *Parameters* + +*key* + +#### *Return value* + +*String* or *Bool*: If key didn't exist, `FALSE` is returned. Otherwise, the value related to this key is returned. + +#### *Examples* + +```php +$valkey->get('key'); +``` + +## getEx + +----- + +_**Description**_: Get the value related to the specified key and set its expiration + +#### *Parameters* + +*key* +*options array* (optional) with the following keys: + * `EX` - expire time in seconds + * `PX` - expire time in milliseconds + * `EXAT` - expire time in seconds since UNIX epoch + * `PXAT` - expire time in milliseconds since UNIX epoch + * `PERSIST` - remove the expiration from the key + +#### *Return value* + +*String* or *Bool*: If key didn't exist, `FALSE` is returned. Otherwise, the value related to this key is returned. + +#### *Examples* + +```php +$valkey->getEx('key', ['EX' => 10]); // get key and set its expiration to 10 seconds +``` + +## set +----- +_**Description**_: Set the string value in argument as value of the key. If you're using Valkey >= 2.6.12, you can pass extended options as explained below + +#### *Parameters* + +*Key* +*Value* +*Timeout or Options Array* (optional). If you pass an integer, valkey-php will redirect to SETEX, and will try to use Valkey >= 2.6.12 extended options if you pass an array with valid values + +#### *Return value* + +*Bool* `TRUE` if the command is successful. + +#### *Examples* + +```php +// Simple key -> value set +$valkey->set('key', 'value'); + +// Will redirect, and actually make an SETEX call +$valkey->set('key','value', 10); + +// Will set the key, if it doesn't exist, with a ttl of 10 seconds +$valkey->set('key', 'value', ['nx', 'ex'=>10]); + +// Will set a key, if it does exist, with a ttl of 1000 milliseconds +$valkey->set('key', 'value', ['xx', 'px'=>1000]); +``` + +## setEx, pSetEx + +----- + +_**Description**_: Set the string value in argument as value of the key, with a time to live. PSETEX uses a TTL in milliseconds. + +#### *Parameters* + +*Key* +*TTL* +*Value* + +#### *Return value* + +*Bool* `TRUE` if the command is successful. + +#### *Examples* + +```php +$valkey->setEx('key', 3600, 'value'); // sets key → value, with 1h TTL. +$valkey->pSetEx('key', 100, 'value'); // sets key → value, with 0.1 sec TTL. +``` + +## setNx +----- +_**Description**_: Set the string value in argument as value of the key if the key doesn't already exist in the database. + +#### *Parameters* +*key* +*value* + +#### *Return value* + +*Bool* `TRUE` in case of success, `FALSE` in case of failure. + +#### *Examples* + +```php +$valkey->setNx('key', 'value'); /* return TRUE */ +$valkey->setNx('key', 'value'); /* return FALSE */ +``` + +## del, delete, unlink + +----- + +_**Description**_: Remove specified keys. + +#### *Parameters* + +An array of keys, or an undefined number of parameters, each a key: *key1* *key2* *key3* ... *keyN* + +*Note*: If you are connecting to Valkey server >= 4.0.0 you can remove a key with the `unlink` method in the exact same way you would use `del`. The Valkey [unlink](https://redis.io/commands/unlink) command is non-blocking and will perform the actual deletion asynchronously. + +#### *Return value* + +*Long* Number of keys deleted. + +#### *Examples* + +```php +$valkey->set('key1', 'val1'); +$valkey->set('key2', 'val2'); +$valkey->set('key3', 'val3'); +$valkey->set('key4', 'val4'); + +$valkey->del('key1', 'key2'); /* return 2 */ +$valkey->del(['key3', 'key4']); /* return 2 */ + +/* If using Valkey >= 4.0.0 you can call unlink */ +$valkey->unlink('key1', 'key2'); +$valkey->unlink(['key1', 'key2']); +``` + +**Note:** `delete` is an alias for `del` and will be removed in future versions of valkey-php. + +## exists + +----- + +_**Description**_: Verify if the specified key exists. + +#### *Parameters* +*key* + +#### *Return value* +*long*: The number of keys tested that do exist. + +#### *Examples* +```php +$valkey->set('key', 'value'); +$valkey->exists('key'); /* 1 */ +$valkey->exists('NonExistingKey'); /* 0 */ + +$valkey->mset(['foo' => 'foo', 'bar' => 'bar', 'baz' => 'baz']); +$valkey->exists(['foo', 'bar', 'baz']); /* 3 */ +$valkey->exists('foo', 'bar', 'baz'); /* 3 */ +``` + +**Note**: This function took a single argument and returned TRUE or FALSE in valkey-php versions < 4.0.0. + +## incr, incrBy +----- +_**Description**_: Increment the number stored at key by one. If the second argument is filled, it will be used as the integer value of the increment. + +#### *Parameters* +*key* +*value*: value that will be added to key (only for incrBy) + +#### *Return value* +*INT* the new value + +#### *Examples* +```php +$valkey->incr('key1'); /* key1 didn't exists, set to 0 before the increment */ + /* and now has the value 1 */ + +$valkey->incr('key1'); /* 2 */ +$valkey->incr('key1'); /* 3 */ +$valkey->incr('key1'); /* 4 */ + +// Will redirect, and actually make an INCRBY call +$valkey->incr('key1', 10); /* 14 */ + +$valkey->incrBy('key1', 10); /* 24 */ +``` + +## incrByFloat +----- +_**Description**_: Increment the key with floating point precision. + +#### *Parameters* +*key* +*value*: (float) value that will be added to the key + +#### *Return value* +*FLOAT* the new value + +#### *Examples* +```php +$valkey->incrByFloat('key1', 1.5); /* key1 didn't exist, so it will now be 1.5 */ + + +$valkey->incrByFloat('key1', 1.5); /* 3 */ +$valkey->incrByFloat('key1', -1.5); /* 1.5 */ +$valkey->incrByFloat('key1', 2.5); /* 4 */ +``` + +## decr, decrBy +----- +_**Description**_: Decrement the number stored at key by one. If the second argument is filled, it will be used as the integer value of the decrement. + +#### *Parameters* +*key* +*value*: value that will be subtracted to key (only for decrBy) + +#### *Return value* +*INT* the new value + +#### *Examples* +```php +$valkey->decr('key1'); /* key1 didn't exists, set to 0 before the increment */ + /* and now has the value -1 */ + +$valkey->decr('key1'); /* -2 */ +$valkey->decr('key1'); /* -3 */ + +// Will redirect, and actually make an DECRBY call +$valkey->decr('key1', 10); /* -13 */ + +$valkey->decrBy('key1', 10); /* -23 */ +``` + +## mGet +----- +_**Description**_: Get the values of all the specified keys. If one or more keys don't exist, the array will contain `FALSE` at the position of the key. + +#### *Parameters* +*Array*: Array containing the list of the keys + +#### *Return value* +*Array*: Array containing the values related to keys in argument + +#### *Examples* +```php +$valkey->set('key1', 'value1'); +$valkey->set('key2', 'value2'); +$valkey->set('key3', 'value3'); +$valkey->mGet(['key1', 'key2', 'key3']); /* ['value1', 'value2', 'value3']; +$valkey->mGet(['key0', 'key1', 'key5']); /* [`FALSE`, 'value1', `FALSE`]; +``` + +## getSet +----- +_**Description**_: Sets a value and returns the previous entry at that key. +#### *Parameters* +*Key*: key + +*STRING*: value + +#### *Return value* +A string, the previous value located at this key. +#### *Example* + +```php +$valkey->set('x', '42'); +$exValue = $valkey->getSet('x', 'lol'); // return '42', replaces x by 'lol' +$newValue = $valkey->get('x')' // return 'lol' +``` + + + +## getRange +----- +_**Description**_: Return a substring of a larger string + +#### *Parameters* +*key* +*start* +*end* + +#### *Return value* +*STRING*: the substring + +#### *Example* + +```php +$valkey->set('key', 'string value'); +$valkey->getRange('key', 0, 5); /* 'string' */ +$valkey->getRange('key', -5, -1); /* 'value' */ +``` + +## setRange +----- +_**Description**_: Changes a substring of a larger string. + +#### *Parameters* +*key* +*offset* +*value* + +#### *Return value* +*STRING*: the length of the string after it was modified. + +#### *Example* + +```php +$valkey->set('key', 'Hello world'); +$valkey->setRange('key', 6, "redis"); /* returns 11 */ +$valkey->get('key'); /* "Hello redis" */ +``` + +## strLen +----- +_**Description**_: Get the length of a string value. + +#### *Parameters* +*key* + +#### *Return value* +*INTEGER* + +#### *Example* + +```php +$valkey->set('key', 'value'); +$valkey->strlen('key'); /* 5 */ +``` + +## mSet, mSetNx +----- +_**Description**_: Sets multiple key-value pairs in one atomic command. MSETNX only returns TRUE if all the keys were set (see SETNX). + +#### *Parameters* +*Pairs*: [key => value, ...] + +#### *Return value* +*Bool* `TRUE` in case of success, `FALSE` in case of failure. + +#### *Example* + +```php + +$valkey->mSet(['key0' => 'value0', 'key1' => 'value1']); +var_dump($valkey->get('key0')); +var_dump($valkey->get('key1')); + +``` +Output: +``` +string(6) "value0" +string(6) "value1" +``` diff --git a/docs/content/technical.md b/docs/content/technical.md index e69de29bb2..cee060405a 100644 --- a/docs/content/technical.md +++ b/docs/content/technical.md @@ -0,0 +1,13 @@ +# Valkey PHP - Technical + +## Pre-requisites + +```bash +brew install valkey +brew services start valkey +brew services list +valkey-cli INFO server + +brew install autoconf automake libtool php +``` + diff --git a/docs/content/transactions.md b/docs/content/transactions.md index e69de29bb2..3b5f2e015d 100644 --- a/docs/content/transactions.md +++ b/docs/content/transactions.md @@ -0,0 +1,78 @@ +# Valkey PHP - Transactions + +|Command |Description |Supported |Tested |Class/Trait |Method | +|--- |--- |:-: |:-: |--- |--- | +|[multi](#multi) |Enter and exit transactional mode. |:white\_check\_mark: |:white\_check\_mark: |Transactions |multi | +|[exec](#exec) |Enter and exit transactional mode. |:white\_check\_mark: |:white\_check\_mark: |Transactions |exec | +|[discard](#discard)|Enter and exit transactional mode. |:white\_check\_mark: |:white\_check\_mark: |Transactions |discard | +|[watch](#watch) |Enter and exit transactional mode. |:white\_check\_mark: |:white\_check\_mark: |Transactions |watch | +|[unwatch](#unwatch)|Enter and exit transactional mode. |:white\_check\_mark: |:white\_check\_mark: |Transactions |unwatch | + +- DISCARD Discards a transaction. +- EXEC Executes all commands in a transaction. +- MULTI Starts a transaction. +- UNWATCH Forgets about watched keys of a transaction. +- WATCH Monitors changes to keys to determine the execution of a transaction. + +## Usage + +```php +$valkey = new Valkey(); +$valkey->connect('127.0.0.1', 6379); +$ret = $valkey->multi() + ->set('key1', 'val1') + ->get('key1') + ->set('key2', 'val2') + ->get('key2') + ->exec(); +``` + +1. [multi, exec, discard](#multi-exec-discard) - Enter and exit transactional mode +2. [watch, unwatch](#watch-unwatch) - Watches a key for modifications by another client. + +### multi, exec, discard. +----- +_**Description**_: Enter and exit transactional mode. + +##### *Parameters* +(optional) `Valkey::MULTI` or `Valkey::PIPELINE`. Defaults to `Valkey::MULTI`. A `Valkey::MULTI` block of commands runs as a single transaction; a `Valkey::PIPELINE` block is simply transmitted faster to the server, but without any guarantee of atomicity. `discard` cancels a transaction. + +##### *Return value* +`multi()` returns the Valkey instance and enters multi-mode. Once in multi-mode, all subsequent method calls return the same object until `exec()` is called. + +##### *Example* + +```php +$ret = $valkey->multi() + ->set('key1', 'val1') + ->get('key1') + ->set('key2', 'val2') + ->get('key2') + ->exec(); + +/* +$ret == [0 => TRUE, 1 => 'val1', 2 => TRUE, 3 => 'val2']; +*/ +``` + +### watch, unwatch +----- +_**Description**_: Watches a key for modifications by another client. + +If the key is modified between `WATCH` and `EXEC`, the MULTI/EXEC transaction will fail (return `FALSE`). `unwatch` cancels all the watching of all keys by this client. + +##### *Parameters* +*keys*: string for one key or array for a list of keys + +##### *Example* + +```php +$valkey->watch('x'); // or for a list of keys: $valkey->watch(['x','another key']); +/* long code here during the execution of which other clients could well modify `x` */ +$ret = $valkey->multi() + ->incr('x') + ->exec(); +/* +$ret = FALSE if x has been modified between the call to WATCH and the call to EXEC. +*/ +``` diff --git a/docs/content/usage.md b/docs/content/usage.md index f93443ced5..6e145bd966 100644 --- a/docs/content/usage.md +++ b/docs/content/usage.md @@ -1,44 +1,42 @@ -# Valkey PHP - Docs +# Valkey PHP Usage -## Usage +1. [Class Valkey](#class-valkey) +2. [Class ValkeyException](#class-valkeyexception) +3. [Predefined constants](#predefined-constants) -1. [Class Redis](#class-redis) -1. [Class RedisException](#class-redisexception) -1. [Predefined constants](#predefined-constants) - -### Class Redis +## Class Valkey ----- -_**Description**_: Creates a Redis client +_**Description**_: Creates a Valkey client -#### *Example* +### *Example* ```php -$redis = new Redis(); +$valkey = new Valkey(); ``` Starting from version 6.0.0 it's possible to specify configuration options. This allows to connect lazily to the server without explicitly invoking `connect` command. -#### *Example* +### *Example* ```php -$redis = new Redis([ +$valkey = new Valkey([ 'host' => '127.0.0.1', 'port' => 6379, 'connectTimeout' => 2.5, - 'auth' => ['phpredis', 'phpredis'], + 'auth' => ['phpvalkey', 'phpvalkey'], 'ssl' => ['verify_peer' => false], 'backoff' => [ - 'algorithm' => Redis::BACKOFF_ALGORITHM_DECORRELATED_JITTER, + 'algorithm' => Valkey::BACKOFF_ALGORITHM_DECORRELATED_JITTER, 'base' => 500, 'cap' => 750, ], ]); ``` -#### *Parameters* +### *Parameters* _host_: string. can be a host, or the path to a unix domain socket. _port_: int (default is 6379, should be -1 for unix domain socket) @@ -49,28 +47,28 @@ _persistent_: mixed, if value is string then it used as persistend id, else valu _auth_: mixed, authentication information _ssl_: array, SSL context options -### Class RedisException +## Class ValkeyException ----- -phpredis throws a [RedisException](#class-redisexception) object if it can't reach the Redis server. That can happen in case of connectivity issues, if the Redis service is down, or if the redis host is overloaded. In any other problematic case that does not involve an -unreachable server (such as a key not existing, an invalid command, etc), phpredis will return `FALSE`. +phpvalkey throws a [ValkeyException](#class-valkeyexception) object if it can't reach the Valkey server. That can happen in case of connectivity issues, if the Valkey service is down, or if the valkey host is overloaded. In any other problematic case that does not involve an +unreachable server (such as a key not existing, an invalid command, etc), phpvalkey will return `FALSE`. -### Predefined constants +## Predefined constants ----- -_**Description**_: Available Redis Constants +_**Description**_: Available Valkey Constants -Redis data types, as returned by [type](#type) +Valkey data types, as returned by [type](#type) ```php -Redis::REDIS_STRING - String -Redis::REDIS_SET - Set -Redis::REDIS_LIST - List -Redis::REDIS_ZSET - Sorted set -Redis::REDIS_HASH - Hash -Redis::REDIS_NOT_FOUND - Not found / other +Valkey::VALKEY_STRING; // String +Valkey::VALKEY_SET; // Set +Valkey::VALKEY_LIST; // List +Valkey::VALKEY_ZSET; // Sorted set +Valkey::VALKEY_HASH; // Hash +Valkey::VALKEY_NOT_FOUND; // Not found / other ``` @TODO: OPT_SERIALIZER, AFTER, BEFORE,... diff --git a/sentinel.md b/sentinel.md index 3afdd83b9c..8fd6017efb 100644 --- a/sentinel.md +++ b/sentinel.md @@ -1,11 +1,11 @@ -Redis Sentinel +Valkey Sentinel ============== -Redis Sentinel provides high availability for Redis. In practical terms this means that using Sentinel you can create a Redis deployment that resists without human intervention certain kinds of failures. +Valkey Sentinel provides high availability for Valkey. In practical terms this means that using Sentinel you can create a Valkey deployment that resists without human intervention certain kinds of failures. -Redis Sentinel also provides other collateral tasks such as monitoring, notifications and acts as a configuration provider for clients. +Valkey Sentinel also provides other collateral tasks such as monitoring, notifications and acts as a configuration provider for clients. -## Class RedisSentinel +## Class ValkeySentinel ----- ##### *Parameters* @@ -21,34 +21,34 @@ Redis Sentinel also provides other collateral tasks such as monitoring, notifica ##### *Examples for version 6.0 or later* ```php -$sentinel = new RedisSentinel([ +$sentinel = new ValkeySentinel([ 'host' => '127.0.0.1', ]); // default parameters -$sentinel = new RedisSentinel([ +$sentinel = new ValkeySentinel([ 'host' => '127.0.0.1', 'port' => 26379, 'connectTimeout' => 2.5, ]); // 2.5 sec timeout. -$sentinel = new RedisSentinel([ +$sentinel = new ValkeySentinel([ 'host' => '127.0.0.1', 'port' => 26379, 'connectTimeout' => 2.5, 'persistent' => 'sentinel', ]); // persistent connection with id 'sentinel' -$sentinel = new RedisSentinel([ +$sentinel = new ValkeySentinel([ 'host' => '127.0.0.1', 'port' => 26379, 'connectTimeout' => 2.5, 'persistent' => '', ]); // also persistent connection with id '' -$sentinel = new RedisSentinel([ +$sentinel = new ValkeySentinel([ 'host' => '127.0.0.1', 'port' => 26379, 'connectTimeout' => 1, 'persistent' => null, 'retryInterval' => 100, ]); // 1 sec timeout, 100ms delay between reconnection attempts. -$sentinel = new RedisSentinel([ +$sentinel = new ValkeySentinel([ 'host' => '127.0.0.1', 'port' => 26379, 'connectTimeout' => 0, @@ -62,12 +62,12 @@ $sentinel = new RedisSentinel([ ##### *Examples for versions older than 6.0* ```php -$sentinel = new RedisSentinel('127.0.0.1'); // default parameters -$sentinel = new RedisSentinel('127.0.0.1', 26379, 2.5); // 2.5 sec timeout. -$sentinel = new RedisSentinel('127.0.0.1', 26379, 0, 'sentinel'); // persistent connection with id 'sentinel' -$sentinel = new RedisSentinel('127.0.0.1', 26379, 0, ''); // also persistent connection with id '' -$sentinel = new RedisSentinel('127.0.0.1', 26379, 1, null, 100); // 1 sec timeout, 100ms delay between reconnection attempts. -$sentinel = new RedisSentinel('127.0.0.1', 26379, 0, NULL, 0, 0, "secret"); // connect sentinel with password authentication +$sentinel = new ValkeySentinel('127.0.0.1'); // default parameters +$sentinel = new ValkeySentinel('127.0.0.1', 26379, 2.5); // 2.5 sec timeout. +$sentinel = new ValkeySentinel('127.0.0.1', 26379, 0, 'sentinel'); // persistent connection with id 'sentinel' +$sentinel = new ValkeySentinel('127.0.0.1', 26379, 0, ''); // also persistent connection with id '' +$sentinel = new ValkeySentinel('127.0.0.1', 26379, 1, null, 100); // 1 sec timeout, 100ms delay between reconnection attempts. +$sentinel = new ValkeySentinel('127.0.0.1', 26379, 0, NULL, 0, 0, "secret"); // connect sentinel with password authentication ``` ### Usage @@ -97,6 +97,7 @@ _**Description**_: Check if the current Sentinel configuration is able to reach *Bool*: `TRUE` in case of success, `FALSE` in case of failure. ##### *Example* + ```php $sentinel->ckquorum('mymaster'); ``` @@ -112,6 +113,7 @@ _**Description**_: Force a failover as if the master was not reachable, and with *Bool*: `TRUE` in case of success, `FALSE` in case of failure. ##### *Example* + ```php $sentinel->failover('mymaster'); ``` @@ -127,6 +129,7 @@ _**Description**_: Force Sentinel to rewrite its configuration on disk, includin *Bool*: `TRUE` in case of success, `FALSE` in case of failure. ##### *Example* + ```php $sentinel->flushconfig(); ``` @@ -142,6 +145,7 @@ _**Description**_: Return the ip and port number of the master with that name. I *Array*, *Bool*: ['address', 'port'] in case of success, `FALSE` in case of failure. ##### *Example* + ```php $sentinel->getMasterAddrByName('mymaster'); ``` @@ -157,6 +161,7 @@ _**Description**_: Return the state and info of the specified master. *Array*, *Bool*: Associative array with info in case of success, `FALSE` in case of failure. ##### *Example* + ```php $sentinel->master('mymaster'); ``` @@ -172,6 +177,7 @@ _**Description**_: Return a list of monitored masters and their state. *Array*, *Bool*: List of arrays with info for each master in case of success, `FALSE` in case of failure. ##### *Example* + ```php $sentinel->masters(); ``` @@ -187,6 +193,7 @@ _**Description**_: Ping the sentinel. *Bool*: `TRUE` in case of success, `FALSE` in case of failure. ##### *Example* + ```php $sentinel->ping(); ``` @@ -202,6 +209,7 @@ _**Description**_: This command will reset all the masters with matching name. T *Bool*: `TRUE` in case of success, `FALSE` in case of failure. ##### *Example* + ```php $sentinel->reset('*'); ``` @@ -217,6 +225,7 @@ _**Description**_: Return a list of sentinel instances for this master, and thei *Array*, *Bool*: List of arrays with info for each sentinels in case of success, `FALSE` in case of failure. ##### *Example* + ```php $sentinel->sentinels('mymaster'); ``` @@ -232,6 +241,7 @@ _**Description**_: Return a list of replicas for this master, and their state. *Array*, *Bool*: List of arrays with info for each replicas in case of success, `FALSE` in case of failure. ##### *Example* + ```php $sentinel->slaves('mymaster'); ``` diff --git a/tests/RedisTest.php b/tests/RedisTest.php index c155c00182..8c5307cc3d 100644 --- a/tests/RedisTest.php +++ b/tests/RedisTest.php @@ -74,9 +74,13 @@ protected function detectValkey(array $info) { public function setUp() { $this->redis = $this->newInstance(); $info = $this->redis->info(); - $this->version = (isset($info['valkey_version'])?$info['valkey_version']:'0.0.0'); $this->is_keydb = $this->detectKeyDB($info); $this->is_valkey = $this->detectValKey($info); + if ($this->is_valkey) { + $this->version = (isset($info['valkey_version'])?$info['valkey_version']:'0.0.0'); + } else { + $this->version = (isset($info['redis_version'])?$info['redis_version']:'0.0.0'); + } } protected function minVersionCheck($version) {