Skip to content

Commit

Permalink
added RedisClient v6 (#75)
Browse files Browse the repository at this point in the history
* added RedisClient v6
  • Loading branch information
cheprasov authored Jun 20, 2020
1 parent b605615 commit c3594e0
Show file tree
Hide file tree
Showing 45 changed files with 1,734 additions and 21 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ php:
- '7.1'
- '7.2'
- '7.3'
- '7.4'
- hhvm

matrix:
Expand Down Expand Up @@ -38,6 +39,8 @@ before_install:
-p 127.0.0.1:6390:6390 \
-p 127.0.0.1:6391:6391 \
-p 127.0.0.1:6392:6392 \
-p 127.0.0.1:6393:6393 \
-p 127.0.0.1:6394:6394 \
cheprasov/redis-for-tests
- |
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
## CHANGELOG

### v1.10.0 (2020-06-20)
- Added support Redis 6
- Updated server commands: ACL commands,
- Updated connection commands: CLIENT ID, CLIENT UNBLOCK, CLIENT CACHING, CLIENT GETREDIR, CLIENT TRACKING, HELLO
- Updated stream commands: XINFO (added FULL param)
- Added lists commands: LPOS
- Added strings commands: STRALGO LCS
- The client was checked with Redis-6.0.5, Redis-5.0.5, Redis-4.0.14 and older versions

### v1.9.1 (2019-10-12)
- Fixed bug: parser result error for transactions/pipelines https://github.com/cheprasov/php-redis-client/issues/72

Expand Down
34 changes: 34 additions & 0 deletions COMMANDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,10 @@
- [flushdb($async = false)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version4x0/ServerCommandsTrait.php)
## Redis version 5.0

### Connection
- [clientId()](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version5x0/ConnectionCommandsTrait.php)
- [clientUnblock($clientId, $timeoutOrError = null)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version5x0/ConnectionCommandsTrait.php)

### Server
- [lolwut($param1 = null, $param2 = null, $param3 = null)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version5x0/ServerCommandsTrait.php)
- [replicaof($host, $port)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version5x0/ServerCommandsTrait.php)
Expand Down Expand Up @@ -333,4 +337,34 @@
- [xrevrange($key, $end, $start, $count = null)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version5x0/StreamsCommandsTrait.php)
- [xtrim($key, $count, $withTilde = false)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version5x0/StreamsCommandsTrait.php)
- [xsetid($stream, $groupname, $id)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version5x0/StreamsCommandsTrait.php)
## Redis version 6.0

### Connection
- [clientCaching($isEnabled)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version6x0/ConnectionCommandsTrait.php)
- [clientCetredir()](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version6x0/ConnectionCommandsTrait.php)
- [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)
- [hello($protover, $username = null, $password = null, $clientName = null)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version6x0/ConnectionCommandsTrait.php)

### Lists
- [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)

### Server
- [aclCat($categoryName = null)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version6x0/ServerCommandsTrait.php)
- [aclDeluser($usernames)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version6x0/ServerCommandsTrait.php)
- [aclGenpass($bits = null)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version6x0/ServerCommandsTrait.php)
- [aclGetuser($username)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version6x0/ServerCommandsTrait.php)
- [aclHelp()](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version6x0/ServerCommandsTrait.php)
- [aclList()](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version6x0/ServerCommandsTrait.php)
- [aclLog($count = null)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version6x0/ServerCommandsTrait.php)
- [aclLogReset()](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version6x0/ServerCommandsTrait.php)
- [aclSave()](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version6x0/ServerCommandsTrait.php)
- [aclSetuser($username, $rules = null)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version6x0/ServerCommandsTrait.php)
- [aclUsers()](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version6x0/ServerCommandsTrait.php)
- [aclWhoami()](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version6x0/ServerCommandsTrait.php)

### Streams
- [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)

### Strings
- [stralgoLcs(array $algoSpecificArguments)](https://github.com/cheprasov/php-redis-client/blob/master/src/RedisClient/Command/Traits/Version6x0/StringsCommandsTrait.php)

18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
[![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)
[![Latest Stable Version](https://poser.pugx.org/cheprasov/php-redis-client/v/stable)](https://packagist.org/packages/cheprasov/php-redis-client)
[![Total Downloads](https://poser.pugx.org/cheprasov/php-redis-client/downloads)](https://packagist.org/packages/cheprasov/php-redis-client)
# RedisClient v1.9.1 for PHP >= 5.5
# RedisClient v1.10.0 for PHP >= 5.5

## About
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__
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__

## Main features
- Support Redis versions from __2.6.x__ to __5.0.x__.
- Support Redis versions from __2.6.x__ to __6.0.x__.
- Support __TCP/IP__ and __UNIX__ sockets.
- Support __PubSub__ and __Monitor__ functionallity.
- Support __Pipeline__ and __Transactions__.
- Support __Redis Cluster__.
- Support __RAW__ commands as arrays `['SET', 'foo', 'bar']`.
- Connections to Redis are established lazily by the client upon the first command.
- Easy to use with IDE, client has PHPDocs for all supported versions.
- By default, the client works with the latest stable version of Redis (5.0).
- 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`.
- Also, the client was tested on PHP `7.3`, `7.2`, `7.1`, `7.0`, `5.6`, `5.5`, `HHVM`.
- By default, the client works with the latest stable version of Redis (6.0).
- 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`.
- Also, the client was tested on PHP `7.4`, `7.3`, `7.2`, `7.1`, `7.0`, `5.6`, `5.5`, `HHVM`.

## Redis Commands

Expand Down Expand Up @@ -100,11 +100,11 @@ use RedisClient\RedisClient;
use RedisClient\Client\Version\RedisClient2x6;
use RedisClient\ClientFactory;

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

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

echo 'RedisClient: '. $Redis->getSupportedVersion() . PHP_EOL; // RedisClient: 2.6

```

### Example
Please, see examples here: https://github.com/cheprasov/php-redis-client/tree/master/examples

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "cheprasov/php-redis-client",
"version": "1.9.1",
"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",
"version": "1.10.0",
"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",
"homepage": "http://github.com/cheprasov/php-redis-client",
"minimum-stability": "stable",
"license": "MIT",
Expand Down
2 changes: 2 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
<const name="TEST_REDIS_SERVER_4x0_2" value="localhost:6390" />
<const name="TEST_REDIS_SERVER_5x0_1" value="127.0.0.1:6391" />
<const name="TEST_REDIS_SERVER_5x0_2" value="localhost:6392" />
<const name="TEST_REDIS_SERVER_6x0_1" value="127.0.0.1:6393" />
<const name="TEST_REDIS_SERVER_6x0_2" value="localhost:6394" />

<const name="TEST_REDIS_SERVER_3x2_CLUSTER_A" value="127.0.0.1:7001" />
<const name="TEST_REDIS_SERVER_3x2_CLUSTER_A1" value="127.0.0.1:7004" />
Expand Down
2 changes: 1 addition & 1 deletion src/RedisClient/Client/AbstractRedisClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

abstract class AbstractRedisClient {

const VERSION = '1.9.1';
const VERSION = '1.10.0';

const CONFIG_SERVER = 'server';
const CONFIG_TIMEOUT = 'timeout';
Expand Down
29 changes: 29 additions & 0 deletions src/RedisClient/Client/Version/RedisClient6x0.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
/**
* This file is part of RedisClient.
* git: https://github.com/cheprasov/php-redis-client
*
* (C) Alexander Cheprasov <acheprasov84@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace RedisClient\Client\Version;

use RedisClient\Client\AbstractRedisClient;
use RedisClient\Command\Traits\Version6x0\CommandsTrait;
use RedisClient\Pipeline\PipelineInterface;
use RedisClient\Pipeline\Version\Pipeline6x0;

class RedisClient6x0 extends AbstractRedisClient {
use CommandsTrait;

/**
* @param \Closure|null $Pipeline
* @return PipelineInterface
*/
protected function createPipeline(\Closure $Pipeline = null) {
return new Pipeline6x0($Pipeline);
}

}
5 changes: 4 additions & 1 deletion src/RedisClient/ClientFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use RedisClient\Client\Version\RedisClient3x2;
use RedisClient\Client\Version\RedisClient4x0;
use RedisClient\Client\Version\RedisClient5x0;
use RedisClient\Client\Version\RedisClient6x0;
use RedisClient\Exception\ErrorException;
use RedisClient\Exception\InvalidArgumentException;

Expand All @@ -27,7 +28,8 @@ class ClientFactory {
const REDIS_VERSION_3x2 = '3.2';
const REDIS_VERSION_4x0 = '4.0';
const REDIS_VERSION_5x0 = '5.0';
const REDIS_VERSION_DEFAULT = self::REDIS_VERSION_5x0;
const REDIS_VERSION_6x0 = '6.0';
const REDIS_VERSION_DEFAULT = self::REDIS_VERSION_6x0;

/**
* @var string|null
Expand All @@ -44,6 +46,7 @@ class ClientFactory {
self::REDIS_VERSION_3x2 => RedisClient3x2::class,
self::REDIS_VERSION_4x0 => RedisClient4x0::class,
self::REDIS_VERSION_5x0 => RedisClient5x0::class,
self::REDIS_VERSION_6x0 => RedisClient6x0::class,
];

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ public function llen($key) {
return $this->returnCommand(['LLEN'], $key, [$key]);
}


/**
* LPOP key
* Available since 1.0.0.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
use RedisClient\Command\Traits\Version3x2\ScriptingCommandsTrait;
use RedisClient\Command\Traits\Version3x2\SetsCommandsTrait;
use RedisClient\Command\Traits\Version3x2\StringsCommandsTrait;
use RedisClient\Command\Traits\Version4x0\ConnectionCommandsTrait;
use RedisClient\Command\Traits\Version4x0\KeysCommandsTrait;
use RedisClient\Command\Traits\Version4x0\MemoryCommandsTrait;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php
/**
* This file is part of RedisClient.
* git: https://github.com/cheprasov/php-redis-client
*
* (C) Alexander Cheprasov <acheprasov84@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace RedisClient\Command\Traits\Version5x0;

use RedisClient\Command\Traits\Version4x0\ConnectionCommandsTrait as ConnectionCommandsTraitVersion4x0;

/**
* Connection Commands
* @link http://redis.io/commands#connection
*/
trait ConnectionCommandsTrait {

use ConnectionCommandsTraitVersion4x0;

/**
* CLIENT ID
* @link http://redis.io/commands/client-id
*
* @return int
*/
public function clientId() {
return $this->returnCommand(['CLIENT', 'ID'], null, null);
}

/**
* CLIENT UNBLOCK client-id [TIMEOUT|ERROR]
* @link https://redis.io/commands/client-unblock
*
* @param int $clientId
* @param string|null $timeoutOrError
* @return int
*/
public function clientUnblock($clientId, $timeoutOrError = null) {
$params = [$clientId];
if ($timeoutOrError) {
$params[] = $timeoutOrError;
}
return $this->returnCommand(['CLIENT', 'UNBLOCK'], null, $params);
}

}
57 changes: 57 additions & 0 deletions src/RedisClient/Command/Traits/Version6x0/CommandsTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php
/**
* This file is part of RedisClient.
* git: https://github.com/cheprasov/php-redis-client
*
* (C) Alexander Cheprasov <acheprasov84@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace RedisClient\Command\Traits\Version6x0;


use RedisClient\Command\Traits\AbstractCommandsTrait;
use RedisClient\Command\Traits\Version2x6\TransactionsCommandsTrait;
use RedisClient\Command\Traits\Version2x8\HyperLogLogCommandsTrait;
use RedisClient\Command\Traits\Version2x8\LatencyCommandsTrait;
use RedisClient\Command\Traits\Version2x8\PubSubCommandsTrait;
use RedisClient\Command\Traits\Version3x0\ClusterCommandsTrait;
use RedisClient\Command\Traits\Version3x2\GeoCommandsTrait;
use RedisClient\Command\Traits\Version3x2\HashesCommandsTrait;
use RedisClient\Command\Traits\Version3x2\ScriptingCommandsTrait;
use RedisClient\Command\Traits\Version3x2\SetsCommandsTrait;
use RedisClient\Command\Traits\Version4x0\KeysCommandsTrait;
use RedisClient\Command\Traits\Version4x0\MemoryCommandsTrait;
use RedisClient\Command\Traits\Version5x0\SortedSetsCommandsTrait;

trait CommandsTrait {

use AbstractCommandsTrait;

use ClusterCommandsTrait;
use ConnectionCommandsTrait;
use GeoCommandsTrait;
use HashesCommandsTrait;
use HyperLogLogCommandsTrait;
use KeysCommandsTrait;
use LatencyCommandsTrait;
use ListsCommandsTrait;
use MemoryCommandsTrait;
use PubSubCommandsTrait;
use ScriptingCommandsTrait;
use ServerCommandsTrait;
use SetsCommandsTrait;
use SortedSetsCommandsTrait;
use StreamsCommandsTrait;
use StringsCommandsTrait;
use TransactionsCommandsTrait;

/**
* @return string
*/
public function getSupportedVersion() {
return '6.0';
}

}
Loading

0 comments on commit c3594e0

Please sign in to comment.