Skip to content

Commit 5fcdc61

Browse files
committed
Merge pull request #40 from cheprasov/dev-1.3.0
v1.3.0
2 parents 7c60fa1 + bf26867 commit 5fcdc61

17 files changed

+359
-59
lines changed

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.3.0 (2016-05-07)
4+
- Client was tested with Redis 3.2.0 (stable)
5+
- Added command **BITFIELD** for Redis >= 3.2.
6+
- Added **STORE** and **STOREDIST** params for **GEORADIUS** and **GEORADIUSBYMEMBER** for Redis >= 3.2.
7+
- Added command **DEBUG HELP** for Redis >= 3.2.
8+
- Changed some test for GEO.
9+
310
### v1.2.3 (2016-05-02)
411
- Fixed command **PING** for Redis <= 2.6.
512
- Added common tests.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
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.2.3 for PHP >= 5.5
4+
# RedisClient v1.3.0 for PHP >= 5.5
55

66
## About
77
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 __3.2.0-RC3__
88

99
## Main features
10-
- Support Redis versions from __2.6__ to __3.2.0-RC3__.
10+
- Support Redis versions from __2.6__ to __3.2.0__.
1111
- Support __TCP/IP__ and __UNIX__ sockets.
1212
- Support __PubSub__ and __Monitor__ functionallity.
1313
- Support __Pipeline__ and __Transactions__.

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.2.3",
3+
"version": "1.3.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 3.2.0-RC3",
55
"homepage": "http://github.com/cheprasov/php-redis-client",
66
"minimum-stability": "stable",

src/RedisClient/Client/AbstractRedisClient.php

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

2121
abstract class AbstractRedisClient {
2222

23-
const VERSION = '1.2.3';
23+
const VERSION = '1.3.0';
2424

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

src/RedisClient/Command/Traits/Version2x8/ServerCommandsTrait.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ public function command() {
4242
* @return int Number of commands returned by COMMAND
4343
*/
4444
public function commandCount() {
45-
// todo: check
4645
return $this->returnCommand(['COMMAND', 'COUNT'], []);
4746
}
4847

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
use RedisClient\Command\Traits\Version2x8\HyperLogLogCommandsTrait;
1919
use RedisClient\Command\Traits\Version2x6\ListsCommandsTrait;
2020
use RedisClient\Command\Traits\Version3x0\SortedSetsCommandsTrait;
21-
use RedisClient\Command\Traits\Version2x8\StringsCommandsTrait;
2221
use RedisClient\Command\Traits\Version2x6\TransactionsCommandsTrait;
2322

2423
trait CommandsTrait {

src/RedisClient/Command/Traits/Version3x2/GeoCommandsTrait.php

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ trait GeoCommandsTrait {
2020

2121
/**
2222
* GEOADD key longitude latitude member [longitude latitude member ...]
23-
* Beta Not yet available in a stable version of Redis. Download unstable if you want to test this command.
23+
* Available since 3.2.0.
2424
* Time complexity: O(log(N)) for each item added, where N is the number of elements in the sorted set.
2525
* @link http://redis.io/commands/geoadd
2626
*
27+
*
2728
* @param string $key
2829
* @param array $members [member => [longitude, latitude]]
2930
* @return int The number of elements added to the sorted set,
@@ -41,7 +42,7 @@ public function geoadd($key, array $members) {
4142

4243
/**
4344
* GEODIST key member1 member2 [unit]
44-
* Beta Not yet available in a stable version of Redis. Download unstable if you want to test this command.
45+
* Available since 3.2.0.
4546
* Time complexity: O(log(N))
4647
* @link http://redis.io/commands/geodist
4748
*
@@ -62,7 +63,7 @@ public function geodist($key, $member1, $member2, $unit = null) {
6263

6364
/**
6465
* GEOHASH key member [member ...]
65-
* Beta Not yet available in a stable version of Redis. Download unstable if you want to test this command.
66+
* Available since 3.2.0.
6667
* Time complexity: O(log(N)) for each member requested, where N is the number of elements in the sorted set.
6768
* @link http://redis.io/commands/geohash
6869
*
@@ -77,7 +78,7 @@ public function geohash($key, $members) {
7778

7879
/**
7980
* GEOPOS key member [member ...]
80-
* Beta Not yet available in a stable version of Redis. Download unstable if you want to test this command.
81+
* Available since 3.2.0.
8182
* Time complexity: O(log(N)) for each member requested, where N is the number of elements in the sorted set.
8283
* @link http://redis.io/commands/geopos
8384
*
@@ -92,8 +93,8 @@ public function geopos($key, $members) {
9293
}
9394

9495
/**
95-
* GEORADIUS key longitude latitude radius m|km|ft|mi [WITHCOORD] [WITHDIST] [WITHHASH] [COUNT count]
96-
* Beta Not yet available in a stable version of Redis. Download unstable if you want to test this command.
96+
* GEORADIUS key longitude latitude radius m|km|ft|mi [WITHCOORD] [WITHDIST] [WITHHASH] [COUNT count] [ASC|DESC] [STORE|STOREDIST key]
97+
* Available since 3.2.0.
9798
* Time complexity: O(N+log(M)) where N is the number of elements inside the bounding box of
9899
* the circular area delimited by center and radius and M is the number of items inside the index.
99100
* @link http://redis.io/commands/georadius
@@ -108,9 +109,14 @@ public function geopos($key, $members) {
108109
* @param bool|false $withhash
109110
* @param int|null $count
110111
* @param bool|null $asc (true => ASC, false => DESC)
111-
* @return array
112+
* @param string|null $storeKey
113+
* @param bool $storeDist
114+
* @return array|int
112115
*/
113-
public function georadius($key, $longitude, $latitude, $radius, $unit, $withcoord = false, $withdist = false, $withhash = false, $count = null, $asc = null) {
116+
public function georadius(
117+
$key, $longitude, $latitude, $radius, $unit, $withcoord = false, $withdist = false,
118+
$withhash = false, $count = null, $asc = null, $storeKey = null, $storeDist = false
119+
) {
114120
$params = [$key, $longitude, $latitude, $radius, $unit];
115121
$parse = false;
116122
if ($withcoord) {
@@ -132,12 +138,17 @@ public function georadius($key, $longitude, $latitude, $radius, $unit, $withcoor
132138
if (isset($asc)) {
133139
$params[] = $asc ? 'ASC' : 'DESC';
134140
}
141+
if (isset($storeKey)) {
142+
$params[] = $storeDist ? 'STOREDIST' : 'STORE';
143+
$params[] = $storeKey;
144+
$parse = false;
145+
}
135146
return $this->returnCommand(['GEORADIUS'], $params, $parse ? ResponseParser::PARSE_GEO_ARRAY : null);
136147
}
137148

138149
/**
139-
* GEORADIUSBYMEMBER key member radius m|km|ft|mi [WITHCOORD] [WITHDIST] [WITHHASH] [COUNT count]
140-
* Beta Not yet available in a stable version of Redis. Download unstable if you want to test this command.
150+
* GEORADIUSBYMEMBER key member radius m|km|ft|mi [WITHCOORD] [WITHDIST] [WITHHASH] [COUNT count] [ASC|DESC] [STORE|STOREDIST key]
151+
* Available since 3.2.0.
141152
* Time complexity: O(N+log(M)) where N is the number of elements inside the bounding box of
142153
* the circular area delimited by center and radius and M is the number of items inside the index.
143154
* @link http://redis.io/commands/georadiusbymember
@@ -151,9 +162,14 @@ public function georadius($key, $longitude, $latitude, $radius, $unit, $withcoor
151162
* @param bool|false $withhash
152163
* @param int|null $count
153164
* @param bool|null $asc (true => ASC, false => DESC)
154-
* @return array
165+
* @param string|null $storeKey
166+
* @param bool $storeDist
167+
* @return array|int
155168
*/
156-
public function georadiusbymember($key, $member, $radius, $unit, $withcoord = false, $withdist = false, $withhash = false, $count = null, $asc = null) {
169+
public function georadiusbymember(
170+
$key, $member, $radius, $unit, $withcoord = false, $withdist = false, $withhash = false,
171+
$count = null, $asc = null, $storeKey = null, $storeDist = false
172+
) {
157173
$params = [$key, $member, $radius, $unit];
158174
$parse = false;
159175
if ($withcoord) {
@@ -175,6 +191,11 @@ public function georadiusbymember($key, $member, $radius, $unit, $withcoord = fa
175191
if (isset($asc)) {
176192
$params[] = $asc ? 'ASC' : 'DESC';
177193
}
194+
if (isset($storeKey)) {
195+
$params[] = $storeDist ? 'STOREDIST' : 'STORE';
196+
$params[] = $storeKey;
197+
$parse = false;
198+
}
178199
return $this->returnCommand(['GEORADIUSBYMEMBER'], $params, $parse ? ResponseParser::PARSE_GEO_ARRAY : null);
179200
}
180201

src/RedisClient/Command/Traits/Version3x2/ServerCommandsTrait.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,14 @@ public function clientReply($param) {
3333
return $this->returnCommand(['CLIENT', 'REPLY'], [$param]);
3434
}
3535

36+
/**
37+
* DEBUG HELP
38+
* Available since 3.2.
39+
*
40+
* @return string[]
41+
*/
42+
public function debugHelp() {
43+
return $this->returnCommand(['DEBUG', 'HELP']);
44+
}
45+
3646
}
Lines changed: 49 additions & 0 deletions
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\Version3x2;
12+
13+
use RedisClient\Command\Traits\Version2x8\StringsCommandsTrait as StringsCommandsTraitVersion2x8;
14+
15+
/**
16+
* Strings Commands
17+
* @link http://redis.io/commands#string
18+
*/
19+
trait StringsCommandsTrait {
20+
21+
use StringsCommandsTraitVersion2x8;
22+
23+
/**
24+
* BITFIELD key [GET type offset] [SET type offset value] [INCRBY type offset increment] [OVERFLOW WRAP|SAT|FAIL]
25+
* Available since 3.2.0.
26+
* Time complexity: O(1) for each subcommand specified
27+
*
28+
* @param string $key
29+
* @param array $subcommands Example: [['GET', 'type', 'offset'], ['OVERFLOW', 'WRAP'], ['SET', 'type', 'offset', 'value']]
30+
* @return mixed
31+
*/
32+
public function bitfield($key, array $subcommands) {
33+
$params = [$key];
34+
// I know, I know... but it is faster!
35+
if (is_array($subcommands[0])) {
36+
foreach ($subcommands as $subcommand) {
37+
foreach ($subcommand as $p) {
38+
$params[] = $p;
39+
}
40+
}
41+
} else {
42+
foreach ($subcommands as $p) {
43+
$params[] = $p;
44+
}
45+
}
46+
return $this->returnCommand(['BITFIELD'], $params);
47+
}
48+
49+
}

src/RedisClient/Pipeline/Version/Pipeline3x2.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@
278278
* @method Pipeline3x2 geodist($key, $member1, $member2, $unit = null)
279279
* @method Pipeline3x2 geohash($key, $members)
280280
* @method Pipeline3x2 geopos($key, $members)
281-
* @method Pipeline3x2 georadius($key, $longitude, $latitude, $radius, $unit, $withcoord = false, $withdist = false, $withhash = false, $count = null, $asc = null)
282-
* @method Pipeline3x2 georadiusbymember($key, $member, $radius, $unit, $withcoord = false, $withdist = false, $withhash = false, $count = null, $asc = null)
281+
* @method Pipeline3x2 georadius($key, $longitude, $latitude, $radius, $unit, $withcoord = false, $withdist = false, $withhash = false, $count = null, $asc = null, $storeKey = null, $storeDist = false)
282+
* @method Pipeline3x2 georadiusbymember($key, $member, $radius, $unit, $withcoord = false, $withdist = false, $withhash = false, $count = null, $asc = null, $storeKey = null, $storeDist = false)
283283
* @method Pipeline3x2 geodel($key, $members)
284284
*
285285
* Hashes
@@ -293,9 +293,13 @@
293293
*
294294
* Server
295295
* @method Pipeline3x2 clientReply($param)
296+
* @method Pipeline3x2 debugHelp()
296297
*
297298
* Sets
298299
* @method Pipeline3x2 spop($key, $count = null)
300+
*
301+
* Strings
302+
* @method Pipeline3x2 bitfield($key, array $subcommands)
299303
*
300304
*/
301305
class Pipeline3x2 extends AbstractPipeline {

tests/Build/VersionTest.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,25 @@ public function test_version() {
1919
$composer = json_decode(file_get_contents('./composer.json'), true);
2020

2121
$this->assertSame(true, isset($composer['version']));
22-
$this->assertSame(AbstractRedisClient::VERSION, $composer['version']);
22+
$this->assertSame(
23+
AbstractRedisClient::VERSION,
24+
$composer['version'],
25+
'Please, change version in composer.json'
26+
);
2327

2428
$readme = file('./README.md');
25-
$this->assertSame(true, strpos($readme[3], 'RedisClient v'.$composer['version']) > 0);
29+
$this->assertSame(
30+
true,
31+
strpos($readme[3], 'RedisClient v'.$composer['version']) > 0,
32+
'Please, change version in README.md'
33+
);
2634

2735
$readme = file('./CHANGELOG.md');
28-
$this->assertSame(true, strpos($readme[2], '### v'.$composer['version']) === 0);
36+
$this->assertSame(
37+
true,
38+
strpos($readme[2], '### v'.$composer['version']) === 0,
39+
'Please, add new version to CHANGELOG.md'
40+
);
2941
}
3042

3143
}

tests/Integration/RedisVersionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ class RedisVersionTest extends \PHPUnit_Framework_TestCase {
2525
[TEST_REDIS_SERVER_2x8_2, '2.8', '2.8.x'],
2626
[TEST_REDIS_SERVER_3x0_1, '3.0', '3.0.x'],
2727
[TEST_REDIS_SERVER_3x0_2, '3.0', '3.0.x'],
28-
[TEST_REDIS_SERVER_3x2_1, '3.2', '3.1.x'],
29-
[TEST_REDIS_SERVER_3x2_2, '3.2', '3.1.x'],
28+
[TEST_REDIS_SERVER_3x2_1, '3.2', '3.2.x'],
29+
[TEST_REDIS_SERVER_3x2_2, '3.2', '3.2.x'],
3030
];
3131

3232
/**

tests/Integration/Version3x0/ServerCommandsTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ public function test_commandCount() {
3838
$this->assertSame(163, $Redis->commandCount());
3939
}
4040

41+
/**
42+
* @see \RedisClient\Command\Traits\Version2x8\ServerCommandsTrait::commandGetkeys
43+
*/
44+
public function _test_commandGetkeys() {
45+
$Redis = static::$Redis;
46+
$this->assertSame(['a', 'c', 'e'], $Redis->commandGetkeys('MSET a b c d e f'));
47+
}
48+
4149
public function test_command() {
4250
$Redis = static::$Redis;
4351

0 commit comments

Comments
 (0)