forked from shumkov/rediska
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
108 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
/** | ||
* Get count of members from sorted set by min and max score | ||
* | ||
* @author Ivan Shumkov | ||
* @package Rediska | ||
* @subpackage Commands | ||
* @version @package_version@ | ||
* @link http://rediska.geometria-lab.net | ||
* @license http://www.opensource.org/licenses/bsd-license.php | ||
*/ | ||
class Rediska_Command_GetSortedSetLengthByScore extends Rediska_Command_Abstract | ||
{ | ||
/** | ||
* Supported version | ||
* | ||
* @var string | ||
*/ | ||
protected $_version = '1.1'; | ||
|
||
/** | ||
* Create command | ||
* | ||
* @param string $key Key name | ||
* @param number $min Min score | ||
* @param number $max Max score | ||
* @return Rediska_Connection_Exec | ||
*/ | ||
public function create($key, $min, $max) | ||
{ | ||
$connection = $this->_rediska->getConnectionByKeyName($key); | ||
|
||
$command = array('ZCOUNT', $this->_rediska->getOption('namespace') . $key, $min, $max); | ||
|
||
return new Rediska_Connection_Exec($connection, $command); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
tests/library/Rediska/Command/GetSortedSetLengthByScoreTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
class Rediska_Command_GetSortedSetLengthByScoreTest extends Rediska_TestCase | ||
{ | ||
public function testGetSortedSetLengthByScore() | ||
{ | ||
$this->rediska->addToSortedSet('test', 1, 1); | ||
$this->rediska->addToSortedSet('test', 2, 2); | ||
$this->rediska->addToSortedSet('test', 3, 3); | ||
|
||
$reply = $this->rediska->getSortedSetLengthByScore('test', 2, 3); | ||
$this->assertEquals(2, $reply); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters