Skip to content

Commit

Permalink
Merge pull request #40 from cheprasov/dev-1.3.0
Browse files Browse the repository at this point in the history
v1.3.0
  • Loading branch information
cheprasov committed May 7, 2016
2 parents 7c60fa1 + bf26867 commit 5fcdc61
Show file tree
Hide file tree
Showing 17 changed files with 359 additions and 59 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
## CHANGELOG

### v1.3.0 (2016-05-07)
- Client was tested with Redis 3.2.0 (stable)
- Added command **BITFIELD** for Redis >= 3.2.
- Added **STORE** and **STOREDIST** params for **GEORADIUS** and **GEORADIUSBYMEMBER** for Redis >= 3.2.
- Added command **DEBUG HELP** for Redis >= 3.2.
- Changed some test for GEO.

### v1.2.3 (2016-05-02)
- Fixed command **PING** for Redis <= 2.6.
- Added common tests.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[![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.2.3 for PHP >= 5.5
# RedisClient v1.3.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 __3.2.0-RC3__

## Main features
- Support Redis versions from __2.6__ to __3.2.0-RC3__.
- Support Redis versions from __2.6__ to __3.2.0__.
- Support __TCP/IP__ and __UNIX__ sockets.
- Support __PubSub__ and __Monitor__ functionallity.
- Support __Pipeline__ and __Transactions__.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cheprasov/php-redis-client",
"version": "1.2.3",
"version": "1.3.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 3.2.0-RC3",
"homepage": "http://github.com/cheprasov/php-redis-client",
"minimum-stability": "stable",
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 @@ -20,7 +20,7 @@

abstract class AbstractRedisClient {

const VERSION = '1.2.3';
const VERSION = '1.3.0';

const CONFIG_SERVER = 'server';
const CONFIG_TIMEOUT = 'timeout';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public function command() {
* @return int Number of commands returned by COMMAND
*/
public function commandCount() {
// todo: check
return $this->returnCommand(['COMMAND', 'COUNT'], []);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use RedisClient\Command\Traits\Version2x8\HyperLogLogCommandsTrait;
use RedisClient\Command\Traits\Version2x6\ListsCommandsTrait;
use RedisClient\Command\Traits\Version3x0\SortedSetsCommandsTrait;
use RedisClient\Command\Traits\Version2x8\StringsCommandsTrait;
use RedisClient\Command\Traits\Version2x6\TransactionsCommandsTrait;

trait CommandsTrait {
Expand Down
45 changes: 33 additions & 12 deletions src/RedisClient/Command/Traits/Version3x2/GeoCommandsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ trait GeoCommandsTrait {

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

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

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

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

/**
* GEORADIUS key longitude latitude radius m|km|ft|mi [WITHCOORD] [WITHDIST] [WITHHASH] [COUNT count]
* Beta Not yet available in a stable version of Redis. Download unstable if you want to test this command.
* GEORADIUS key longitude latitude radius m|km|ft|mi [WITHCOORD] [WITHDIST] [WITHHASH] [COUNT count] [ASC|DESC] [STORE|STOREDIST key]
* Available since 3.2.0.
* Time complexity: O(N+log(M)) where N is the number of elements inside the bounding box of
* the circular area delimited by center and radius and M is the number of items inside the index.
* @link http://redis.io/commands/georadius
Expand All @@ -108,9 +109,14 @@ public function geopos($key, $members) {
* @param bool|false $withhash
* @param int|null $count
* @param bool|null $asc (true => ASC, false => DESC)
* @return array
* @param string|null $storeKey
* @param bool $storeDist
* @return array|int
*/
public function georadius($key, $longitude, $latitude, $radius, $unit, $withcoord = false, $withdist = false, $withhash = false, $count = null, $asc = null) {
public function georadius(
$key, $longitude, $latitude, $radius, $unit, $withcoord = false, $withdist = false,
$withhash = false, $count = null, $asc = null, $storeKey = null, $storeDist = false
) {
$params = [$key, $longitude, $latitude, $radius, $unit];
$parse = false;
if ($withcoord) {
Expand All @@ -132,12 +138,17 @@ public function georadius($key, $longitude, $latitude, $radius, $unit, $withcoor
if (isset($asc)) {
$params[] = $asc ? 'ASC' : 'DESC';
}
if (isset($storeKey)) {
$params[] = $storeDist ? 'STOREDIST' : 'STORE';
$params[] = $storeKey;
$parse = false;
}
return $this->returnCommand(['GEORADIUS'], $params, $parse ? ResponseParser::PARSE_GEO_ARRAY : null);
}

/**
* GEORADIUSBYMEMBER key member radius m|km|ft|mi [WITHCOORD] [WITHDIST] [WITHHASH] [COUNT count]
* Beta Not yet available in a stable version of Redis. Download unstable if you want to test this command.
* GEORADIUSBYMEMBER key member radius m|km|ft|mi [WITHCOORD] [WITHDIST] [WITHHASH] [COUNT count] [ASC|DESC] [STORE|STOREDIST key]
* Available since 3.2.0.
* Time complexity: O(N+log(M)) where N is the number of elements inside the bounding box of
* the circular area delimited by center and radius and M is the number of items inside the index.
* @link http://redis.io/commands/georadiusbymember
Expand All @@ -151,9 +162,14 @@ public function georadius($key, $longitude, $latitude, $radius, $unit, $withcoor
* @param bool|false $withhash
* @param int|null $count
* @param bool|null $asc (true => ASC, false => DESC)
* @return array
* @param string|null $storeKey
* @param bool $storeDist
* @return array|int
*/
public function georadiusbymember($key, $member, $radius, $unit, $withcoord = false, $withdist = false, $withhash = false, $count = null, $asc = null) {
public function georadiusbymember(
$key, $member, $radius, $unit, $withcoord = false, $withdist = false, $withhash = false,
$count = null, $asc = null, $storeKey = null, $storeDist = false
) {
$params = [$key, $member, $radius, $unit];
$parse = false;
if ($withcoord) {
Expand All @@ -175,6 +191,11 @@ public function georadiusbymember($key, $member, $radius, $unit, $withcoord = fa
if (isset($asc)) {
$params[] = $asc ? 'ASC' : 'DESC';
}
if (isset($storeKey)) {
$params[] = $storeDist ? 'STOREDIST' : 'STORE';
$params[] = $storeKey;
$parse = false;
}
return $this->returnCommand(['GEORADIUSBYMEMBER'], $params, $parse ? ResponseParser::PARSE_GEO_ARRAY : null);
}

Expand Down
10 changes: 10 additions & 0 deletions src/RedisClient/Command/Traits/Version3x2/ServerCommandsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,14 @@ public function clientReply($param) {
return $this->returnCommand(['CLIENT', 'REPLY'], [$param]);
}

/**
* DEBUG HELP
* Available since 3.2.
*
* @return string[]
*/
public function debugHelp() {
return $this->returnCommand(['DEBUG', 'HELP']);
}

}
49 changes: 49 additions & 0 deletions src/RedisClient/Command/Traits/Version3x2/StringsCommandsTrait.php
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 <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace RedisClient\Command\Traits\Version3x2;

use RedisClient\Command\Traits\Version2x8\StringsCommandsTrait as StringsCommandsTraitVersion2x8;

/**
* Strings Commands
* @link http://redis.io/commands#string
*/
trait StringsCommandsTrait {

use StringsCommandsTraitVersion2x8;

/**
* BITFIELD key [GET type offset] [SET type offset value] [INCRBY type offset increment] [OVERFLOW WRAP|SAT|FAIL]
* Available since 3.2.0.
* Time complexity: O(1) for each subcommand specified
*
* @param string $key
* @param array $subcommands Example: [['GET', 'type', 'offset'], ['OVERFLOW', 'WRAP'], ['SET', 'type', 'offset', 'value']]
* @return mixed
*/
public function bitfield($key, array $subcommands) {
$params = [$key];
// I know, I know... but it is faster!
if (is_array($subcommands[0])) {
foreach ($subcommands as $subcommand) {
foreach ($subcommand as $p) {
$params[] = $p;
}
}
} else {
foreach ($subcommands as $p) {
$params[] = $p;
}
}
return $this->returnCommand(['BITFIELD'], $params);
}

}
8 changes: 6 additions & 2 deletions src/RedisClient/Pipeline/Version/Pipeline3x2.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@
* @method Pipeline3x2 geodist($key, $member1, $member2, $unit = null)
* @method Pipeline3x2 geohash($key, $members)
* @method Pipeline3x2 geopos($key, $members)
* @method Pipeline3x2 georadius($key, $longitude, $latitude, $radius, $unit, $withcoord = false, $withdist = false, $withhash = false, $count = null, $asc = null)
* @method Pipeline3x2 georadiusbymember($key, $member, $radius, $unit, $withcoord = false, $withdist = false, $withhash = false, $count = null, $asc = null)
* @method Pipeline3x2 georadius($key, $longitude, $latitude, $radius, $unit, $withcoord = false, $withdist = false, $withhash = false, $count = null, $asc = null, $storeKey = null, $storeDist = false)
* @method Pipeline3x2 georadiusbymember($key, $member, $radius, $unit, $withcoord = false, $withdist = false, $withhash = false, $count = null, $asc = null, $storeKey = null, $storeDist = false)
* @method Pipeline3x2 geodel($key, $members)
*
* Hashes
Expand All @@ -293,9 +293,13 @@
*
* Server
* @method Pipeline3x2 clientReply($param)
* @method Pipeline3x2 debugHelp()
*
* Sets
* @method Pipeline3x2 spop($key, $count = null)
*
* Strings
* @method Pipeline3x2 bitfield($key, array $subcommands)
*
*/
class Pipeline3x2 extends AbstractPipeline {
Expand Down
18 changes: 15 additions & 3 deletions tests/Build/VersionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,25 @@ public function test_version() {
$composer = json_decode(file_get_contents('./composer.json'), true);

$this->assertSame(true, isset($composer['version']));
$this->assertSame(AbstractRedisClient::VERSION, $composer['version']);
$this->assertSame(
AbstractRedisClient::VERSION,
$composer['version'],
'Please, change version in composer.json'
);

$readme = file('./README.md');
$this->assertSame(true, strpos($readme[3], 'RedisClient v'.$composer['version']) > 0);
$this->assertSame(
true,
strpos($readme[3], 'RedisClient v'.$composer['version']) > 0,
'Please, change version in README.md'
);

$readme = file('./CHANGELOG.md');
$this->assertSame(true, strpos($readme[2], '### v'.$composer['version']) === 0);
$this->assertSame(
true,
strpos($readme[2], '### v'.$composer['version']) === 0,
'Please, add new version to CHANGELOG.md'
);
}

}
4 changes: 2 additions & 2 deletions tests/Integration/RedisVersionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class RedisVersionTest extends \PHPUnit_Framework_TestCase {
[TEST_REDIS_SERVER_2x8_2, '2.8', '2.8.x'],
[TEST_REDIS_SERVER_3x0_1, '3.0', '3.0.x'],
[TEST_REDIS_SERVER_3x0_2, '3.0', '3.0.x'],
[TEST_REDIS_SERVER_3x2_1, '3.2', '3.1.x'],
[TEST_REDIS_SERVER_3x2_2, '3.2', '3.1.x'],
[TEST_REDIS_SERVER_3x2_1, '3.2', '3.2.x'],
[TEST_REDIS_SERVER_3x2_2, '3.2', '3.2.x'],
];

/**
Expand Down
8 changes: 8 additions & 0 deletions tests/Integration/Version3x0/ServerCommandsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ public function test_commandCount() {
$this->assertSame(163, $Redis->commandCount());
}

/**
* @see \RedisClient\Command\Traits\Version2x8\ServerCommandsTrait::commandGetkeys
*/
public function _test_commandGetkeys() {
$Redis = static::$Redis;
$this->assertSame(['a', 'c', 'e'], $Redis->commandGetkeys('MSET a b c d e f'));
}

public function test_command() {
$Redis = static::$Redis;

Expand Down
Loading

0 comments on commit 5fcdc61

Please sign in to comment.