Fix implementation for hash tags extraction from keys.

We now fully comply with the specifications defined by Redis.
This commit is contained in:
Daniele Alessandri
2014-02-11 18:22:03 +01:00
parent d89027d2da
commit 8fbe658ca8
2 changed files with 10 additions and 3 deletions
+2 -2
View File
@@ -305,8 +305,8 @@ class RedisStrategy implements StrategyInterface
protected function extractKeyTag($key)
{
if (false !== $start = strpos($key, '{')) {
if (false !== $end = strpos($key, '}', $start)) {
$key = substr($key, ++$start, $end - $start);
if (false !== ($end = strpos($key, '}', $start)) && $end !== ++$start) {
$key = substr($key, $start, $end - $start);
}
}
+8 -1
View File
@@ -29,7 +29,14 @@ class RedisStrategyTest extends PredisTestCase
$this->assertSame(44950, $strategy->getKeyHash('{foo}'));
$this->assertSame(44950, $strategy->getKeyHash('{foo}:bar'));
$this->assertSame(44950, $strategy->getKeyHash('{foo}:baz'));
$this->assertSame(44950, $strategy->getKeyHash('bar:{foo}:bar'));
$this->assertSame(44950, $strategy->getKeyHash('bar:{foo}:baz'));
$this->assertSame(44950, $strategy->getKeyHash('bar:{foo}:{baz}'));
$this->assertSame(44950, $strategy->getKeyHash('bar:{foo}:baz{}'));
$this->assertSame(9415, $strategy->getKeyHash('{}bar:{foo}:baz'));
$this->assertSame(0, $strategy->getKeyHash(''));
$this->assertSame(31641, $strategy->getKeyHash('{}'));
}
/**