Skip to content

Commit 6be9210

Browse files
Merge pull request phpredis#2016 from phpredis/release/pr/5.3.5-rc1
PhpRedis 5.3.5-rc1 PR
2 parents e3426c1 + ffcdbbf commit 6be9210

30 files changed

+1052
-446
lines changed

.github/workflows/ci.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
on: [push, pull_request]
2+
3+
jobs:
4+
build:
5+
runs-on: ubuntu-latest
6+
continue-on-error: ${{ matrix.experimental }}
7+
strategy:
8+
fail-fast: false
9+
matrix:
10+
php: ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
11+
experimental: [false]
12+
include:
13+
- php: '8.1'
14+
experimental: true
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v2
18+
with:
19+
submodules: true
20+
- name: Install PHP ${{ matrix.php }}
21+
uses: shivammathur/setup-php@v2
22+
with:
23+
php-version: ${{ matrix.php }}
24+
extensions: json, igbinary, msgpack, :redis
25+
coverage: none
26+
tools: none
27+
- name: Install dependencies
28+
run: |
29+
sudo add-apt-repository ppa:redislabs/redis
30+
sudo add-apt-repository ppa:ondrej/php
31+
sudo apt-get update
32+
sudo apt-get install redis valgrind libzstd-dev liblz4-dev
33+
- name: Build phpredis
34+
run: |
35+
phpize
36+
./configure --enable-redis-lzf --enable-redis-zstd --enable-redis-igbinary --enable-redis-msgpack --enable-redis-lz4 --with-liblz4
37+
sudo make install
38+
echo 'extension = redis.so' | sudo tee -a $(php --ini | grep 'Scan for additional .ini files' | awk '{print $7}')/90-redis.ini
39+
- name: Start redis
40+
run: |
41+
redis-cli SHUTDOWN NOSAVE
42+
for PORT in $(seq 6379 6382) $(seq 32767 32769); do
43+
redis-server --port $PORT --daemonize yes --aclfile tests/users.acl
44+
done
45+
redis-server --port 0 --unixsocket /tmp/redis.sock --daemonize yes --aclfile tests/users.acl
46+
- name: Start redis cluster
47+
run: |
48+
mkdir -p tests/nodes
49+
echo -n > tests/nodes/nodemap
50+
for PORT in $(seq 7000 7011); do
51+
redis-server --port $PORT --cluster-enabled yes --cluster-config-file $PORT.conf --daemonize yes --aclfile tests/users.acl
52+
echo 127.0.0.1:$PORT >> tests/nodes/nodemap
53+
done
54+
echo yes | redis-cli --cluster create $(seq -f 127.0.0.1:%g 7000 7011) --cluster-replicas 3 --user phpredis -a phpredis
55+
- name: Start redis sentinel
56+
run: |
57+
wget raw.githubusercontent.com/redis/redis/6.2/sentinel.conf
58+
for PORT in $(seq 26379 26380); do
59+
cp sentinel.conf $PORT.conf
60+
sed -i '/^sentinel/d' $PORT.conf
61+
redis-server $PORT.conf --port $PORT --daemonize yes --sentinel monitor mymaster 127.0.0.1 6379 1 --sentinel auth-pass mymaster phpredis
62+
done
63+
- name: Run tests
64+
run: |
65+
php tests/TestRedis.php --class Redis --user phpredis --auth phpredis
66+
php tests/TestRedis.php --class RedisArray --user phpredis --auth phpredis
67+
php tests/TestRedis.php --class RedisCluster --user phpredis --auth phpredis
68+
php tests/TestRedis.php --class RedisSentinel --auth phpredis
69+
env:
70+
TEST_PHP_ARGS: -e
71+
- name: Run tests using valgrind
72+
continue-on-error: true
73+
run: |
74+
valgrind --error-exitcode=1 php tests/TestRedis.php --class Redis --user phpredis --auth phpredis
75+
valgrind --error-exitcode=1 php tests/TestRedis.php --class RedisArray --user phpredis --auth phpredis
76+
valgrind --error-exitcode=1 php tests/TestRedis.php --class RedisCluster --user phpredis --auth phpredis
77+
valgrind --error-exitcode=1 php tests/TestRedis.php --class RedisSentinel --auth phpredis
78+
env:
79+
TEST_PHP_ARGS: -e
80+
USE_ZEND_ALLOC: 0

.travis.yml

Lines changed: 0 additions & 67 deletions
This file was deleted.

INSTALL.markdown

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
1-
# Installation from pecl
1+
# Installation from pecl/pickle
22

3-
To pull latest stable released version, from [pecl](https://pecl.php.net/package/redis):
3+
To pull latest stable released version, from [pecl](https://pecl.php.net/package/redis) / [pickle](https://wiki.php.net/rfc/deprecate-pear-include-composer):
44

55
~~~
66
pecl install redis
7+
8+
// If using PHP >= 7.3
9+
pickle install redis
710
~~~
811

912
# Installation from sources
1013

1114
To build this extension for the sources tree:
1215

1316
~~~
17+
git clone https://github.com/phpredis/phpredis.git
18+
cd phpredis
1419
phpize
1520
./configure [--enable-redis-igbinary] [--enable-redis-msgpack] [--enable-redis-lzf [--with-liblzf[=DIR]]] [--enable-redis-zstd]
1621
make && make install
@@ -84,7 +89,7 @@ See also: [Install Redis & PHP Extension PHPRedis with Macports](http://www.lecl
8489
You can install it using MacPorts:
8590

8691
- [Get macports-php](https://www.macports.org/)
87-
- `sudo port install php56-redis` (or php53-redis, php54-redis, php55-redis, php70-redis, php71-redis, php72-redis)
92+
- `sudo port install php56-redis` (or php53-redis, php54-redis, php55-redis, php70-redis, php71-redis, php72-redis, php73-redis, php74-redis)
8893

8994
# Building on Windows
9095

README.markdown

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# PhpRedis
22

3-
[![Build Status](https://travis-ci.org/phpredis/phpredis.svg?branch=develop)](https://travis-ci.org/phpredis/phpredis)
3+
[![Build Status](https://github.com/phpredis/phpredis/actions/workflows/ci.yml/badge.svg)](https://github.com/phpredis/phpredis/actions/workflows/ci.yml)
44
[![Coverity Scan Build Status](https://scan.coverity.com/projects/13205/badge.svg)](https://scan.coverity.com/projects/phpredis-phpredis)
5+
[![PHP version from Travis config](https://img.shields.io/travis/php-v/phpredis/phpredis/develop)](https://img.shields.io/travis/php-v/phpredis/phpredis/develop)
56

67
The phpredis extension provides an API for communicating with the [Redis](http://redis.io/) key-value store. It is released under the [PHP License, version 3.01](http://www.php.net/license/3_01.txt).
78
This code has been developed and maintained by Owlient from November 2009 to March 2011.
@@ -34,6 +35,7 @@ You can also make a one-time contribution with one of the links below.
3435
1. [Classes and methods](#classes-and-methods)
3536
* [Usage](#usage)
3637
* [Connection](#connection)
38+
* [Retry and backoff](#retry-and-backoff)
3739
* [Server](#server)
3840
* [Keys and strings](#keys-and-strings)
3941
* [Hashes](#hashes)
@@ -77,7 +79,7 @@ session.save_path = "tcp://host1:6379?weight=1, tcp://host2:6379?weight=2&timeou
7779

7880
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).
7981
The session handler requires a version of Redis supporting `EX` and `NX` options of `SET` command (at least 2.6.12).
80-
phpredis can also connect to a unix domain socket: `session.save_path = "unix:///var/run/redis/redis.sock?persistent=1&weight=1&database=0`.
82+
phpredis can also connect to a unix domain socket: `session.save_path = "unix:///var/run/redis/redis.sock?persistent=1&weight=1&database=0"`.
8183

8284
### Session locking
8385

@@ -293,7 +295,7 @@ $redis->auth(['phpredis', 'haxx00r']);
293295
$redis->auth(['foobared']);
294296

295297
/* You can also use an associative array specifying user and pass */
296-
$redis->auth(['user' => 'phpredis', 'pass' => 'phpredis]);
298+
$redis->auth(['user' => 'phpredis', 'pass' => 'phpredis']);
297299
$redis->auth(['pass' => 'phpredis']);
298300
~~~
299301

@@ -356,6 +358,7 @@ $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_NONE); // Don't ser
356358
$redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP); // Use built-in serialize/unserialize
357359
$redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_IGBINARY); // Use igBinary serialize/unserialize
358360
$redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_MSGPACK); // Use msgpack serialize/unserialize
361+
$redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_JSON); // Use JSON to serialize/unserialize
359362

360363
$redis->setOption(Redis::OPT_PREFIX, 'myAppName:'); // use custom prefix on all keys
361364

@@ -388,7 +391,7 @@ Parameter value.
388391
##### *Example*
389392
~~~php
390393
// return Redis::SERIALIZER_NONE, Redis::SERIALIZER_PHP,
391-
// Redis::SERIALIZER_IGBINARY, or Redis::SERIALIZER_MSGPACK
394+
// Redis::SERIALIZER_IGBINARY, Redis::SERIALIZER_MSGPACK or Redis::SERIALIZER_JSON
392395
$redis->getOption(Redis::OPT_SERIALIZER);
393396
~~~
394397

@@ -427,6 +430,41 @@ _**Description**_: Sends a string to Redis, which replies with the same string
427430

428431
*STRING*: the same message.
429432

433+
## Retry and backoff
434+
435+
1. [Maximum retries](#maximum-retries)
436+
1. [Backoff algorithms](#backoff-algorithms)
437+
438+
### Maximum retries
439+
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_ attemps overall. Defaults to 10.
440+
441+
##### *Example*
442+
443+
~~~php
444+
$redis->setOption(Redis::OPT_MAX_RETRIES, 5);
445+
$redis->getOption(Redis::OPT_MAX_RETRIES);
446+
~~~
447+
448+
### Backoff algorithms
449+
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):
450+
451+
* Default: `Redis::BACKOFF_ALGORITHM_DEFAULT`
452+
* Decorrelated jitter: `Redis::BACKOFF_ALGORITHM_DECORRELATED_JITTER`
453+
* Full jitter: `Redis::BACKOFF_ALGORITHM_FULL_JITTER`
454+
* Equal jitter: `Redis::BACKOFF_ALGORITHM_EQUAL_JITTER`
455+
* Exponential: `Redis::BACKOFF_ALGORITHM_EXPONENTIAL`
456+
* Uniform: `Redis::BACKOFF_ALGORITHM_UNIFORM`
457+
* Constant: `Redis::BACKOFF_ALGORITHM_CONSTANT`
458+
459+
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.
460+
461+
##### *Example*
462+
463+
~~~php
464+
$redis->setOption(Redis::OPT_BACKOFF_ALGORITHM, Redis::BACKOFF_ALGORITHM_DECORRELATED_JITTER);
465+
$redis->setOption(Redis::OPT_BACKOFF_BASE, 500); // base for backoff computation: 500ms
466+
$redis->setOption(Redis::OPT_BACKOFF_CAP, 750); // backoff time capped at 750ms
467+
~~~
430468

431469
## Server
432470

@@ -882,7 +920,7 @@ $redis->exists('key'); /* 1 */
882920
$redis->exists('NonExistingKey'); /* 0 */
883921

884922
$redis->mset(['foo' => 'foo', 'bar' => 'bar', 'baz' => 'baz']);
885-
$redis->exists(['foo', 'bar', 'baz]); /* 3 */
923+
$redis->exists(['foo', 'bar', 'baz']); /* 3 */
886924
$redis->exists('foo', 'bar', 'baz'); /* 3 */
887925
~~~
888926

@@ -2254,7 +2292,7 @@ $redis->lLen('key1');/* 2 */
22542292

22552293
### sAdd
22562294
-----
2257-
_**Description**_: Adds a value to the set value stored at key. If this value is already in the set, `FALSE` is returned.
2295+
_**Description**_: Adds a value to the set value stored at key.
22582296
##### *Parameters*
22592297
*key*
22602298
*value*
@@ -2615,7 +2653,7 @@ $redis->sAdd('s2', '4');
26152653
var_dump($redis->sUnion('s0', 's1', 's2'));
26162654

26172655
/* Pass a single array */
2618-
var_dump($redis->sUnion(['s0', 's1', 's2']);
2656+
var_dump($redis->sUnion(['s0', 's1', 's2']));
26192657

26202658
~~~
26212659
Return value: all elements that are either in s0 or in s1 or in s2.
@@ -3794,7 +3832,7 @@ $obj_redis->xRange('mystream', '-', '+', 2);
37943832

37953833
##### *Prototype*
37963834
~~~php
3797-
$obj_redis->xRead($arr_streams [, $i_count, $i_block);
3835+
$obj_redis->xRead($arr_streams [, $i_count, $i_block]);
37983836
~~~
37993837

38003838
_**Description**_: Read data from one or more streams and only return IDs greater than sent in the command.
@@ -4010,7 +4048,7 @@ $redis->rawCommand("set", "foo", "bar");
40104048
$redis->rawCommand("get", "foo");
40114049

40124050
/* Returns: 3 */
4013-
$redis->rawCommand("rpush", "mylist", "one", 2, 3.5));
4051+
$redis->rawCommand("rpush", "mylist", "one", 2, 3.5);
40144052

40154053
/* Returns: ["one", "2", "3.5000000000000000"] */
40164054
$redis->rawCommand("lrange", "mylist", 0, -1);

0 commit comments

Comments
 (0)