Skip to content

Commit c3594e0

Browse files
authored
added RedisClient v6 (#75)
* added RedisClient v6
1 parent b605615 commit c3594e0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1734
-21
lines changed

.travis.yml

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ php:
88
- '7.1'
99
- '7.2'
1010
- '7.3'
11+
- '7.4'
1112
- hhvm
1213

1314
matrix:
@@ -38,6 +39,8 @@ before_install:
3839
-p 127.0.0.1:6390:6390 \
3940
-p 127.0.0.1:6391:6391 \
4041
-p 127.0.0.1:6392:6392 \
42+
-p 127.0.0.1:6393:6393 \
43+
-p 127.0.0.1:6394:6394 \
4144
cheprasov/redis-for-tests
4245
4346
- |

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
## CHANGELOG
22

3+
### v1.10.0 (2020-06-20)
4+
- Added support Redis 6
5+
- Updated server commands: ACL commands,
6+
- Updated connection commands: CLIENT ID, CLIENT UNBLOCK, CLIENT CACHING, CLIENT GETREDIR, CLIENT TRACKING, HELLO
7+
- Updated stream commands: XINFO (added FULL param)
8+
- Added lists commands: LPOS
9+
- Added strings commands: STRALGO LCS
10+
- The client was checked with Redis-6.0.5, Redis-5.0.5, Redis-4.0.14 and older versions
11+
312
### v1.9.1 (2019-10-12)
413
- Fixed bug: parser result error for transactions/pipelines https://github.com/cheprasov/php-redis-client/issues/72
514

COMMANDS.md

+34
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,10 @@
304304
- [flushdb($async = false)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version4x0/ServerCommandsTrait.php)
305305
## Redis version 5.0
306306

307+
### Connection
308+
- [clientId()](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version5x0/ConnectionCommandsTrait.php)
309+
- [clientUnblock($clientId, $timeoutOrError = null)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version5x0/ConnectionCommandsTrait.php)
310+
307311
### Server
308312
- [lolwut($param1 = null, $param2 = null, $param3 = null)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version5x0/ServerCommandsTrait.php)
309313
- [replicaof($host, $port)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version5x0/ServerCommandsTrait.php)
@@ -333,4 +337,34 @@
333337
- [xrevrange($key, $end, $start, $count = null)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version5x0/StreamsCommandsTrait.php)
334338
- [xtrim($key, $count, $withTilde = false)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version5x0/StreamsCommandsTrait.php)
335339
- [xsetid($stream, $groupname, $id)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version5x0/StreamsCommandsTrait.php)
340+
## Redis version 6.0
341+
342+
### Connection
343+
- [clientCaching($isEnabled)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version6x0/ConnectionCommandsTrait.php)
344+
- [clientCetredir()](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version6x0/ConnectionCommandsTrait.php)
345+
- [clientTracking($isEnabled, $redirectClientId = null, $prefixes = null, $bcast = null, $optin = null, $optout = null, $noloop = null)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version6x0/ConnectionCommandsTrait.php)
346+
- [hello($protover, $username = null, $password = null, $clientName = null)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version6x0/ConnectionCommandsTrait.php)
347+
348+
### Lists
349+
- [lpos($key, $element, $rank = null, $numMatches = null, $len = null)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version6x0/ListsCommandsTrait.php)
350+
351+
### Server
352+
- [aclCat($categoryName = null)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version6x0/ServerCommandsTrait.php)
353+
- [aclDeluser($usernames)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version6x0/ServerCommandsTrait.php)
354+
- [aclGenpass($bits = null)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version6x0/ServerCommandsTrait.php)
355+
- [aclGetuser($username)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version6x0/ServerCommandsTrait.php)
356+
- [aclHelp()](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version6x0/ServerCommandsTrait.php)
357+
- [aclList()](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version6x0/ServerCommandsTrait.php)
358+
- [aclLog($count = null)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version6x0/ServerCommandsTrait.php)
359+
- [aclLogReset()](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version6x0/ServerCommandsTrait.php)
360+
- [aclSave()](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version6x0/ServerCommandsTrait.php)
361+
- [aclSetuser($username, $rules = null)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version6x0/ServerCommandsTrait.php)
362+
- [aclUsers()](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version6x0/ServerCommandsTrait.php)
363+
- [aclWhoami()](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version6x0/ServerCommandsTrait.php)
364+
365+
### Streams
366+
- [xinfo($consumersKey = null, $consumersGroup = null, $groupsKey = null, $streamKey = null, $streamFull = null, $help = false)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version6x0/StreamsCommandsTrait.php)
367+
368+
### Strings
369+
- [stralgoLcs(array $algoSpecificArguments)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version6x0/StringsCommandsTrait.php)
336370

README.md

+9-9
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.9.1 for PHP >= 5.5
4+
# RedisClient v1.10.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 __5.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 __6.0__
88

99
## Main features
10-
- Support Redis versions from __2.6.x__ to __5.0.x__.
10+
- Support Redis versions from __2.6.x__ to __6.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 (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`.
18+
- By default, the client works with the latest stable version of Redis (6.0).
19+
- The client was tested on the next latest versions of Redis: `6.0.5`, `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.4`, `7.3`, `7.2`, `7.1`, `7.0`, `5.6`, `5.5`, `HHVM`.
2121

2222
## Redis Commands
2323

@@ -100,11 +100,11 @@ use RedisClient\RedisClient;
100100
use RedisClient\Client\Version\RedisClient2x6;
101101
use RedisClient\ClientFactory;
102102

103-
// Example 1. Create new Instance for Redis version 2.8.x with config via factory
103+
// Example 1. Create new Instance for Redis version 6.0.x with config via factory
104104
$Redis = ClientFactory::create([
105105
'server' => '127.0.0.1:6379', // or 'unix:///tmp/redis.sock'
106106
'timeout' => 2,
107-
'version' => '2.8.24'
107+
'version' => '6.0'
108108
]);
109109

110110
echo 'RedisClient: '. $Redis->getSupportedVersion() . PHP_EOL; // RedisClient: 2.8
@@ -135,8 +135,8 @@ $Redis = new RedisClient2x6([
135135
]);
136136

137137
echo 'RedisClient: '. $Redis->getSupportedVersion() . PHP_EOL; // RedisClient: 2.6
138-
139138
```
139+
140140
### Example
141141
Please, see examples here: https://github.com/cheprasov/php-redis-client/tree/master/examples
142142

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "cheprasov/php-redis-client",
3-
"version": "1.9.1",
4-
"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 5.0",
3+
"version": "1.10.0",
4+
"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 6.0",
55
"homepage": "http://github.com/cheprasov/php-redis-client",
66
"minimum-stability": "stable",
77
"license": "MIT",

phpunit.xml

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
<const name="TEST_REDIS_SERVER_4x0_2" value="localhost:6390" />
4646
<const name="TEST_REDIS_SERVER_5x0_1" value="127.0.0.1:6391" />
4747
<const name="TEST_REDIS_SERVER_5x0_2" value="localhost:6392" />
48+
<const name="TEST_REDIS_SERVER_6x0_1" value="127.0.0.1:6393" />
49+
<const name="TEST_REDIS_SERVER_6x0_2" value="localhost:6394" />
4850

4951
<const name="TEST_REDIS_SERVER_3x2_CLUSTER_A" value="127.0.0.1:7001" />
5052
<const name="TEST_REDIS_SERVER_3x2_CLUSTER_A1" value="127.0.0.1:7004" />

src/RedisClient/Client/AbstractRedisClient.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
abstract class AbstractRedisClient {
2828

29-
const VERSION = '1.9.1';
29+
const VERSION = '1.10.0';
3030

3131
const CONFIG_SERVER = 'server';
3232
const CONFIG_TIMEOUT = 'timeout';
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\Version6x0\CommandsTrait;
15+
use RedisClient\Pipeline\PipelineInterface;
16+
use RedisClient\Pipeline\Version\Pipeline6x0;
17+
18+
class RedisClient6x0 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 Pipeline6x0($Pipeline);
27+
}
28+
29+
}

src/RedisClient/ClientFactory.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use RedisClient\Client\Version\RedisClient3x2;
1717
use RedisClient\Client\Version\RedisClient4x0;
1818
use RedisClient\Client\Version\RedisClient5x0;
19+
use RedisClient\Client\Version\RedisClient6x0;
1920
use RedisClient\Exception\ErrorException;
2021
use RedisClient\Exception\InvalidArgumentException;
2122

@@ -27,7 +28,8 @@ class ClientFactory {
2728
const REDIS_VERSION_3x2 = '3.2';
2829
const REDIS_VERSION_4x0 = '4.0';
2930
const REDIS_VERSION_5x0 = '5.0';
30-
const REDIS_VERSION_DEFAULT = self::REDIS_VERSION_5x0;
31+
const REDIS_VERSION_6x0 = '6.0';
32+
const REDIS_VERSION_DEFAULT = self::REDIS_VERSION_6x0;
3133

3234
/**
3335
* @var string|null
@@ -44,6 +46,7 @@ class ClientFactory {
4446
self::REDIS_VERSION_3x2 => RedisClient3x2::class,
4547
self::REDIS_VERSION_4x0 => RedisClient4x0::class,
4648
self::REDIS_VERSION_5x0 => RedisClient5x0::class,
49+
self::REDIS_VERSION_6x0 => RedisClient6x0::class,
4750
];
4851

4952
/**

src/RedisClient/Command/Traits/Version2x6/ListsCommandsTrait.php

-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ public function llen($key) {
108108
return $this->returnCommand(['LLEN'], $key, [$key]);
109109
}
110110

111-
112111
/**
113112
* LPOP key
114113
* Available since 1.0.0.

src/RedisClient/Command/Traits/Version5x0/CommandsTrait.php

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
use RedisClient\Command\Traits\Version3x2\ScriptingCommandsTrait;
2323
use RedisClient\Command\Traits\Version3x2\SetsCommandsTrait;
2424
use RedisClient\Command\Traits\Version3x2\StringsCommandsTrait;
25-
use RedisClient\Command\Traits\Version4x0\ConnectionCommandsTrait;
2625
use RedisClient\Command\Traits\Version4x0\KeysCommandsTrait;
2726
use RedisClient\Command\Traits\Version4x0\MemoryCommandsTrait;
2827

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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\Version4x0\ConnectionCommandsTrait as ConnectionCommandsTraitVersion4x0;
14+
15+
/**
16+
* Connection Commands
17+
* @link http://redis.io/commands#connection
18+
*/
19+
trait ConnectionCommandsTrait {
20+
21+
use ConnectionCommandsTraitVersion4x0;
22+
23+
/**
24+
* CLIENT ID
25+
* @link http://redis.io/commands/client-id
26+
*
27+
* @return int
28+
*/
29+
public function clientId() {
30+
return $this->returnCommand(['CLIENT', 'ID'], null, null);
31+
}
32+
33+
/**
34+
* CLIENT UNBLOCK client-id [TIMEOUT|ERROR]
35+
* @link https://redis.io/commands/client-unblock
36+
*
37+
* @param int $clientId
38+
* @param string|null $timeoutOrError
39+
* @return int
40+
*/
41+
public function clientUnblock($clientId, $timeoutOrError = null) {
42+
$params = [$clientId];
43+
if ($timeoutOrError) {
44+
$params[] = $timeoutOrError;
45+
}
46+
return $this->returnCommand(['CLIENT', 'UNBLOCK'], null, $params);
47+
}
48+
49+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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\Version6x0;
12+
13+
14+
use RedisClient\Command\Traits\AbstractCommandsTrait;
15+
use RedisClient\Command\Traits\Version2x6\TransactionsCommandsTrait;
16+
use RedisClient\Command\Traits\Version2x8\HyperLogLogCommandsTrait;
17+
use RedisClient\Command\Traits\Version2x8\LatencyCommandsTrait;
18+
use RedisClient\Command\Traits\Version2x8\PubSubCommandsTrait;
19+
use RedisClient\Command\Traits\Version3x0\ClusterCommandsTrait;
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\Version4x0\KeysCommandsTrait;
25+
use RedisClient\Command\Traits\Version4x0\MemoryCommandsTrait;
26+
use RedisClient\Command\Traits\Version5x0\SortedSetsCommandsTrait;
27+
28+
trait CommandsTrait {
29+
30+
use AbstractCommandsTrait;
31+
32+
use ClusterCommandsTrait;
33+
use ConnectionCommandsTrait;
34+
use GeoCommandsTrait;
35+
use HashesCommandsTrait;
36+
use HyperLogLogCommandsTrait;
37+
use KeysCommandsTrait;
38+
use LatencyCommandsTrait;
39+
use ListsCommandsTrait;
40+
use MemoryCommandsTrait;
41+
use PubSubCommandsTrait;
42+
use ScriptingCommandsTrait;
43+
use ServerCommandsTrait;
44+
use SetsCommandsTrait;
45+
use SortedSetsCommandsTrait;
46+
use StreamsCommandsTrait;
47+
use StringsCommandsTrait;
48+
use TransactionsCommandsTrait;
49+
50+
/**
51+
* @return string
52+
*/
53+
public function getSupportedVersion() {
54+
return '6.0';
55+
}
56+
57+
}

0 commit comments

Comments
 (0)