New command: STRLEN (Redis v2.2-dev).

This commit is contained in:
Daniele Alessandri
2010-09-25 16:31:35 +02:00
parent d3ba25436c
commit 9ae47c865e
2 changed files with 20 additions and 0 deletions
+7
View File
@@ -1811,6 +1811,9 @@ class RedisServer_vNext extends RedisServer_v2_0 {
/* transactions */
'watch' => '\Predis\Commands\Watch',
'unwatch' => '\Predis\Commands\Unwatch',
/* commands operating on string values */
'strlen' => '\Predis\Commands\Strlen',
));
}
}
@@ -2338,6 +2341,10 @@ class Substr extends \Predis\MultiBulkCommand {
public function getCommandId() { return 'SUBSTR'; }
}
class Strlen extends \Predis\MultiBulkCommand {
public function getCommandId() { return 'STRLEN'; }
}
/* commands operating on the key space */
class Keys extends \Predis\MultiBulkCommand {
public function canBeHashed() { return false; }
+13
View File
@@ -240,6 +240,19 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
});
}
function testStrlen() {
$this->redis->set('var', 'foobar');
$this->assertEquals(6, $this->redis->strlen('var'));
$this->assertEquals(9, $this->redis->append('var', '___'));
$this->assertEquals(9, $this->redis->strlen('var'));
RC::testForServerException($this, RC::EXCEPTION_WRONG_TYPE, function($test) {
$test->redis->rpush('metavars', 'foo');
$test->redis->strlen('metavars');
});
}
/* commands operating on the key space */
function testKeys() {