Skip to content

Commit 9bd8634

Browse files
authored
Added Support Redis v 5
1 parent 1cf77be commit 9bd8634

38 files changed

+1644
-15
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ php:
77
- '7.0'
88
- '7.1'
99
- '7.2'
10+
- '7.3'
1011
- hhvm
1112

1213
matrix:
@@ -35,6 +36,8 @@ before_install:
3536
-p 127.0.0.1:6388:6388 \
3637
-p 127.0.0.1:6389:6389 \
3738
-p 127.0.0.1:6390:6390 \
39+
-p 127.0.0.1:6391:6391 \
40+
-p 127.0.0.1:6392:6392 \
3841
cheprasov/redis-for-tests
3942
4043
- |

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
## CHANGELOG
22

3+
### v1.9.0 (2019-07-16)
4+
- Support Redis 5
5+
- Added stream commands: XACK, XADD, XCLAIM, XDEL, XGROUP, XINFO, XLEN, XPENDING, XRANGE, XREAD, XREADGROUP, XREVRANGE, XTRIM.
6+
- Added server commands: LOLWUT, REPLICAOF
7+
- Added sorted sets commands: BZPOPMAX, BZPOPMIN, ZPOPMAX, ZPOPMIN
8+
- The client was checked with Redis-5.0.5, Redis-4.0.14 and older versions
9+
310
### v1.8.0 (2018-03-08)
411
- Added configuration for connection: timeout & flags.
512

COMMANDS.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,4 +302,35 @@
302302
### Server
303303
- [flushall($async = false)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version4x0/ServerCommandsTrait.php)
304304
- [flushdb($async = false)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version4x0/ServerCommandsTrait.php)
305+
## Redis version 5.0
306+
307+
### Server
308+
- [lolwut($param1 = null, $param2 = null, $param3 = null)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version5x0/ServerCommandsTrait.php)
309+
- [replicaof($host, $port)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version5x0/ServerCommandsTrait.php)
310+
311+
### SortedSets
312+
- [bzpopmax($keys, $timeout = 0)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version5x0/SortedSetsCommandsTrait.php)
313+
- [bzpopmin($keys, $timeout = 0)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version5x0/SortedSetsCommandsTrait.php)
314+
- [zpopmax($key, $count = null)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version5x0/SortedSetsCommandsTrait.php)
315+
- [zpopmin($key, $count = null)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version5x0/SortedSetsCommandsTrait.php)
316+
317+
### Streams
318+
- [xack($key, $group, $ids)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version5x0/StreamsCommandsTrait.php)
319+
- [xadd($key, $id, $fieldStrings, $maxlen = null)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version5x0/StreamsCommandsTrait.php)
320+
- [xclaim($key, $group, $consumer, $minIdleTime, $ids, $idle = null, $time = null, $retrycount = null, $force = false, $justid = false)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version5x0/StreamsCommandsTrait.php)
321+
- [xdel($key, $ids)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version5x0/StreamsCommandsTrait.php)
322+
- [xgroupCreate($key, $groupname, $id)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version5x0/StreamsCommandsTrait.php)
323+
- [xgroupSetid($key, $groupname, $id)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version5x0/StreamsCommandsTrait.php)
324+
- [xgroupDestroy($key, $groupname)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version5x0/StreamsCommandsTrait.php)
325+
- [xgroupDelconsumer($key, $groupname, $consumername)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version5x0/StreamsCommandsTrait.php)
326+
- [xgroupHelp()](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version5x0/StreamsCommandsTrait.php)
327+
- [xinfo($consumersKey = null, $consumersGroup = null, $groupsKey = null, $streamKey = null, $help = false)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version5x0/StreamsCommandsTrait.php)
328+
- [xlen($key)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version5x0/StreamsCommandsTrait.php)
329+
- [xpending($key, $group, $start = null, $end = null, $count = null, $consumer = null)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version5x0/StreamsCommandsTrait.php)
330+
- [xrange($key, $start, $end, $count = null)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version5x0/StreamsCommandsTrait.php)
331+
- [xread($keys, $ids, $count = null, $block = null)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version5x0/StreamsCommandsTrait.php)
332+
- [xreadgroup($group, $consumer, $keys, $ids, $noack = false, $count = null, $block = null)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version5x0/StreamsCommandsTrait.php)
333+
- [xrevrange($key, $end, $start, $count = null)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version5x0/StreamsCommandsTrait.php)
334+
- [xtrim($key, $count, $withTilde = false)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version5x0/StreamsCommandsTrait.php)
335+
- [xsetid($stream, $groupname, $id)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version5x0/StreamsCommandsTrait.php)
305336

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
[![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)
22
[![Latest Stable Version](https://poser.pugx.org/cheprasov/php-redis-client/v/stable)](https://packagist.org/packages/cheprasov/php-redis-client)
33
[![Total Downloads](https://poser.pugx.org/cheprasov/php-redis-client/downloads)](https://packagist.org/packages/cheprasov/php-redis-client)
4-
# RedisClient v1.8.0 for PHP >= 5.5
4+
# RedisClient v1.9.0 for PHP >= 5.5
55

66
## About
7-
RedisClient is a fast, fully-functional and user-friendly client for Redis, optimized for performance. RedisClient supports the latest versions of Redis starting from __2.6__ to __4.0__
7+
RedisClient is a fast, fully-functional and user-friendly client for Redis, optimized for performance. RedisClient supports the latest versions of Redis starting from __2.6__ to __5.0__
88

99
## Main features
10-
- Support Redis versions from __2.6.x__ to __4.0.x__.
10+
- Support Redis versions from __2.6.x__ to __5.0.x__.
1111
- Support __TCP/IP__ and __UNIX__ sockets.
1212
- Support __PubSub__ and __Monitor__ functionallity.
1313
- Support __Pipeline__ and __Transactions__.
1414
- Support __Redis Cluster__.
1515
- Support __RAW__ commands as arrays `['SET', 'foo', 'bar']`.
1616
- Connections to Redis are established lazily by the client upon the first command.
1717
- Easy to use with IDE, client has PHPDocs for all supported versions.
18-
- By default, the client works with the latest stable version of Redis (4.0).
19-
- The client was tested on the next latest versions of Redis: 2.6.17, 2.8.24, 3.0.7, 3.2.8, 4.0.10.
20-
- Also, the client was tested on PHP 5.5, 5.6, 7.0, 7.1, 7.2, HHVM.
18+
- By default, the client works with the latest stable version of Redis (5.0).
19+
- The client was tested on the next latest versions of Redis: `5.0.5`, `4.0.14`, `3.2.8`, `3.0.7`, `2.8.24`, `2.6.17`.
20+
- Also, the client was tested on PHP `7.3`, `7.2`, `7.1`, `7.0`, `5.6`, `5.5`, `HHVM`.
2121

2222
## Redis Commands
2323

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cheprasov/php-redis-client",
3-
"version": "1.8.0",
3+
"version": "1.9.0",
44
"description": "Php client for Redis. It is a fast, fully-functional and user-friendly client for Redis, optimized for performance. RedisClient supports the latest versions of Redis starting from 2.6 to 4.0",
55
"homepage": "http://github.com/cheprasov/php-redis-client",
66
"minimum-stability": "stable",

phpunit.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
<const name="TEST_REDIS_SERVER_3x2_2" value="localhost:6388" />
4444
<const name="TEST_REDIS_SERVER_4x0_1" value="127.0.0.1:6389" />
4545
<const name="TEST_REDIS_SERVER_4x0_2" value="localhost:6390" />
46+
<const name="TEST_REDIS_SERVER_5x0_1" value="127.0.0.1:6391" />
47+
<const name="TEST_REDIS_SERVER_5x0_2" value="localhost:6392" />
4648

4749
<const name="TEST_REDIS_SERVER_3x2_CLUSTER_A" value="127.0.0.1:7001" />
4850
<const name="TEST_REDIS_SERVER_3x2_CLUSTER_A1" value="127.0.0.1:7004" />

src/RedisClient/Client/AbstractRedisClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
abstract class AbstractRedisClient {
2828

29-
const VERSION = '1.8.0';
29+
const VERSION = '1.9.0';
3030

3131
const CONFIG_SERVER = 'server';
3232
const CONFIG_TIMEOUT = 'timeout';
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
/**
3+
* This file is part of RedisClient.
4+
* git: https://github.com/cheprasov/php-redis-client
5+
*
6+
* (C) Alexander Cheprasov <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
namespace RedisClient\Client\Version;
12+
13+
use RedisClient\Client\AbstractRedisClient;
14+
use RedisClient\Command\Traits\Version5x0\CommandsTrait;
15+
use RedisClient\Pipeline\PipelineInterface;
16+
use RedisClient\Pipeline\Version\Pipeline5x0;
17+
18+
class RedisClient5x0 extends AbstractRedisClient {
19+
use CommandsTrait;
20+
21+
/**
22+
* @param \Closure|null $Pipeline
23+
* @return PipelineInterface
24+
*/
25+
protected function createPipeline(\Closure $Pipeline = null) {
26+
return new Pipeline5x0($Pipeline);
27+
}
28+
29+
}

src/RedisClient/ClientFactory.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use RedisClient\Client\Version\RedisClient3x0;
1616
use RedisClient\Client\Version\RedisClient3x2;
1717
use RedisClient\Client\Version\RedisClient4x0;
18+
use RedisClient\Client\Version\RedisClient5x0;
1819
use RedisClient\Exception\ErrorException;
1920
use RedisClient\Exception\InvalidArgumentException;
2021

@@ -25,7 +26,8 @@ class ClientFactory {
2526
const REDIS_VERSION_3x0 = '3.0';
2627
const REDIS_VERSION_3x2 = '3.2';
2728
const REDIS_VERSION_4x0 = '4.0';
28-
const REDIS_VERSION_DEFAULT = self::REDIS_VERSION_4x0;
29+
const REDIS_VERSION_5x0 = '5.0';
30+
const REDIS_VERSION_DEFAULT = self::REDIS_VERSION_5x0;
2931

3032
/**
3133
* @var string|null
@@ -41,6 +43,7 @@ class ClientFactory {
4143
self::REDIS_VERSION_3x0 => RedisClient3x0::class,
4244
self::REDIS_VERSION_3x2 => RedisClient3x2::class,
4345
self::REDIS_VERSION_4x0 => RedisClient4x0::class,
46+
self::REDIS_VERSION_5x0 => RedisClient5x0::class,
4447
];
4548

4649
/**
@@ -77,7 +80,7 @@ public static function setDefaultRedisVersion($version) {
7780

7881
/**
7982
* @param null|array $config
80-
* @return RedisClient2x6|RedisClient2x8|RedisClient3x0|RedisClient3x2|RedisClient4x0|RedisClient
83+
* @return RedisClient2x6|RedisClient2x8|RedisClient3x0|RedisClient3x2|RedisClient4x0|RedisClient5x0|RedisClient
8184
*/
8285
public static function create($config = null) {
8386
if (isset($config['version'])) {
@@ -89,7 +92,7 @@ public static function create($config = null) {
8992
/**
9093
* @param string $version
9194
* @param null|array $config
92-
* @return RedisClient2x6|RedisClient2x8|RedisClient3x0|RedisClient3x2|RedisClient4x0
95+
* @return RedisClient2x6|RedisClient2x8|RedisClient3x0|RedisClient3x2|RedisClient4x0|RedisClient5x0
9396
* @throws InvalidArgumentException
9497
*/
9598
public static function createClientByVersion($version, $config = null) {
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
/**
3+
* This file is part of RedisClient.
4+
* git: https://github.com/cheprasov/php-redis-client
5+
*
6+
* (C) Alexander Cheprasov <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
namespace RedisClient\Command\Traits\Version5x0;
12+
13+
use RedisClient\Command\Traits\AbstractCommandsTrait;
14+
use RedisClient\Command\Traits\Version2x8\LatencyCommandsTrait;
15+
use RedisClient\Command\Traits\Version2x8\PubSubCommandsTrait;
16+
use RedisClient\Command\Traits\Version3x0\ClusterCommandsTrait;
17+
use RedisClient\Command\Traits\Version2x8\HyperLogLogCommandsTrait;
18+
use RedisClient\Command\Traits\Version2x6\ListsCommandsTrait;
19+
use RedisClient\Command\Traits\Version2x6\TransactionsCommandsTrait;
20+
use RedisClient\Command\Traits\Version3x2\GeoCommandsTrait;
21+
use RedisClient\Command\Traits\Version3x2\HashesCommandsTrait;
22+
use RedisClient\Command\Traits\Version3x2\ScriptingCommandsTrait;
23+
use RedisClient\Command\Traits\Version3x2\SetsCommandsTrait;
24+
use RedisClient\Command\Traits\Version3x2\StringsCommandsTrait;
25+
use RedisClient\Command\Traits\Version4x0\ConnectionCommandsTrait;
26+
use RedisClient\Command\Traits\Version4x0\KeysCommandsTrait;
27+
use RedisClient\Command\Traits\Version4x0\MemoryCommandsTrait;
28+
29+
trait CommandsTrait {
30+
31+
use AbstractCommandsTrait;
32+
33+
use ClusterCommandsTrait;
34+
use ConnectionCommandsTrait;
35+
use GeoCommandsTrait;
36+
use HashesCommandsTrait;
37+
use HyperLogLogCommandsTrait;
38+
use KeysCommandsTrait;
39+
use LatencyCommandsTrait;
40+
use ListsCommandsTrait;
41+
use MemoryCommandsTrait;
42+
use PubSubCommandsTrait;
43+
use ScriptingCommandsTrait;
44+
use ServerCommandsTrait;
45+
use SetsCommandsTrait;
46+
use SortedSetsCommandsTrait;
47+
use StreamsCommandsTrait;
48+
use StringsCommandsTrait;
49+
use TransactionsCommandsTrait;
50+
51+
/**
52+
* @return string
53+
*/
54+
public function getSupportedVersion() {
55+
return '5.0';
56+
}
57+
58+
}

0 commit comments

Comments
 (0)