Skip to content

Commit b4a34b0

Browse files
committed
Merge pull request #35 from cheprasov/fix-cluster-bugs
fix some cluster bugs
2 parents 9779351 + 5f2e82a commit b4a34b0

File tree

5 files changed

+24
-15
lines changed

5 files changed

+24
-15
lines changed

README.md

+18-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
[![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)
22

3-
# RedisClient v1.2.0 for PHP >= 5.5
3+
# RedisClient v1.2.1 for PHP >= 5.5
44

55
## About
6-
RedisClient is a fast, fully-functional and user-friendly client for Redis, optimized for performance. RedisClient supports latests versions of Redis starting from 2.6
6+
RedisClient is a fast, fully-functional and user-friendly client for Redis, optimized for performance. RedisClient supports latest versions of Redis starting from __2.6__
77

88
## Main features
99
- Support Redis versions from __2.6__ to __3.2.0-RC3__.
1010
- Support TCP/IP and UNIX sockets.
11-
- Support __PubSub__ and __monitor__ functionallity.
12-
- Support __pipeline__.
11+
- Support __PubSub__ and __Monitor__ functionallity.
12+
- Support __Pipeline__ and __Transactions__.
1313
- Support RAW commands as strings `"SET foo bar"` or as arrays `['SET', 'foo', 'bar']`.
1414
- Connections to Redis are established lazily by the client upon the first command.
1515
- Easy to use with IDE, client has PHPDocs for all supported versions.
@@ -26,7 +26,7 @@ require (dirname(__DIR__).'/vendor/autoload.php');
2626
use RedisClient\RedisClient;
2727
use RedisClient\Client\Version\RedisClient2x6;
2828

29-
// Create new Instance for Redis version 2.8.x with config via factory
29+
// Example 1. Create new Instance for Redis version 2.8.x with config via factory
3030

3131
$Redis = ClientFactory::create([
3232
'server' => 'tcp://127.0.0.1:6379', // or 'unix:///tmp/redis.sock'
@@ -37,7 +37,19 @@ $Redis = ClientFactory::create([
3737
echo 'RedisClient: '. $Redis->getSupportedVersion() . PHP_EOL;
3838
// RedisClient: 2.8
3939

40-
// Create new instance of client without factory
40+
41+
// Example 2. Create new Instance for Redis version 2.6.x with config
42+
43+
$Redis = new RedisClient2x6([
44+
'server' => 'tcp://127.0.0.1:6379', // or 'unix:///tmp/redis.sock'
45+
'timeout' => 2
46+
]);
47+
48+
echo 'RedisClient: '. $Redis->getSupportedVersion() . PHP_EOL;
49+
// RedisClient: 2.6
50+
51+
52+
// Example 3. Create new instance of client without factory
4153

4254
$Redis = new RedisClient([
4355
'server' => 'tcp://127.0.0.1:6379', // or 'unix:///tmp/redis.sock'

composer.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cheprasov/php-redis-client",
3-
"version": "1.2.0",
3+
"version": "1.2.1",
44
"description": "Php client for Redis",
55
"homepage": "http://github.com/cheprasov/php-redis-client",
66
"minimum-stability": "stable",
@@ -20,7 +20,6 @@
2020
"php": ">=5.5"
2121
},
2222
"require-dev": {
23-
"phpunit/phpunit": "5.1.*",
24-
"cheprasov/php-simple-profiler": "master-dev"
23+
"phpunit/phpunit": "5.1.*"
2524
}
2625
}

src/RedisClient/Client/AbstractRedisClient.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
abstract class AbstractRedisClient {
2222

23-
const VERSION = '1.2.0';
23+
const VERSION = '1.2.1';
2424

2525
const CONFIG_SERVER = 'server';
2626
const CONFIG_TIMEOUT = 'timeout';

src/RedisClient/Command/Traits/Version3x0/ClusterCommandsTrait.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function clusterAddslots($slots) {
3939
* @return int The number of active failure reports for the node.
4040
*/
4141
public function clusterCountFailureReports($nodeId) {
42-
return $this->returnCommand(['PUBLISH'], [$nodeId]);
42+
return $this->returnCommand(['CLUSTER', 'COUNT-FAILURE-REPORTS'], [$nodeId]);
4343
}
4444

4545
/**
@@ -197,7 +197,7 @@ public function clusterReset($option = null) {
197197
* @return bool
198198
*/
199199
public function clusterSaveconfig() {
200-
return $this->returnCommand(['CLUSTER SAVECONFIG']);
200+
return $this->returnCommand(['CLUSTER', 'SAVECONFIG']);
201201
}
202202

203203
/**
@@ -226,7 +226,7 @@ public function clusterSetConfigEpoch($config) {
226226
*/
227227
public function clusterSetslot($slot, $subcommand, $nodeId = null) {
228228
$params = [$slot, $subcommand];
229-
if ($nodeId) {
229+
if (isset($nodeId)) {
230230
$params[] = $nodeId;
231231
}
232232
return $this->returnCommand(['CLUSTER', 'SETSLOT'], $params);

src/RedisClient/Protocol/RedisProtocol.php

-2
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,10 @@ protected function read() {
138138
throw new UnknownTypeException('Unknown protocol type '. $type);
139139
}
140140

141-
142141
/**
143142
* @inheritdoc
144143
*/
145144
public function send(array $structures) {
146-
//echo str_replace(['\n','\r'], '-', json_encode($structures))." => ";
147145
$this->write($this->packProtocolArray($structures));
148146
return $response = $this->read();
149147
}

0 commit comments

Comments
 (0)