Procházet zdrojové kódy

Move key prefixing logic from command classes to prefix processor.

While command classes define how the client should filter arguments or
parse responses, key prefixing depends on the actual command signature
as defined by Redis so it really is something that should be handled
separately as the norm.

Developers can define new handlers or override existing ones, but they
can still define the key prefixing logic inside their command classes
by implementing Predis\Command\PrefixableCommandInterface: the key
prefix processor will just use that by overriding any defined handler.
Daniele Alessandri před 11 roky
rodič
revize
d0b431016d
100 změnil soubory, kde provedl 415 přidání a 486 odebrání
  1. 5 0
      CHANGELOG.md
  2. 1 1
      lib/Predis/Command/HashDelete.php
  3. 1 1
      lib/Predis/Command/HashExists.php
  4. 1 1
      lib/Predis/Command/HashGet.php
  5. 1 1
      lib/Predis/Command/HashGetAll.php
  6. 1 1
      lib/Predis/Command/HashGetMultiple.php
  7. 1 1
      lib/Predis/Command/HashIncrementBy.php
  8. 1 1
      lib/Predis/Command/HashIncrementByFloat.php
  9. 1 1
      lib/Predis/Command/HashKeys.php
  10. 1 1
      lib/Predis/Command/HashLength.php
  11. 1 1
      lib/Predis/Command/HashScan.php
  12. 1 1
      lib/Predis/Command/HashSet.php
  13. 1 1
      lib/Predis/Command/HashSetMultiple.php
  14. 1 1
      lib/Predis/Command/HashSetPreserve.php
  15. 1 1
      lib/Predis/Command/HashValues.php
  16. 1 9
      lib/Predis/Command/KeyDelete.php
  17. 1 1
      lib/Predis/Command/KeyDump.php
  18. 1 1
      lib/Predis/Command/KeyExists.php
  19. 1 1
      lib/Predis/Command/KeyExpire.php
  20. 1 1
      lib/Predis/Command/KeyExpireAt.php
  21. 1 1
      lib/Predis/Command/KeyKeys.php
  22. 1 1
      lib/Predis/Command/KeyMove.php
  23. 1 1
      lib/Predis/Command/KeyPersist.php
  24. 1 9
      lib/Predis/Command/KeyRename.php
  25. 1 1
      lib/Predis/Command/KeyRestore.php
  26. 1 35
      lib/Predis/Command/KeySort.php
  27. 1 1
      lib/Predis/Command/KeyTimeToLive.php
  28. 1 1
      lib/Predis/Command/KeyType.php
  29. 1 1
      lib/Predis/Command/ListIndex.php
  30. 1 1
      lib/Predis/Command/ListInsert.php
  31. 1 1
      lib/Predis/Command/ListLength.php
  32. 1 1
      lib/Predis/Command/ListPopFirst.php
  33. 1 9
      lib/Predis/Command/ListPopFirstBlocking.php
  34. 1 1
      lib/Predis/Command/ListPopLast.php
  35. 1 9
      lib/Predis/Command/ListPopLastPushHead.php
  36. 1 9
      lib/Predis/Command/ListPopLastPushHeadBlocking.php
  37. 1 1
      lib/Predis/Command/ListPushHeadX.php
  38. 1 1
      lib/Predis/Command/ListPushTail.php
  39. 1 1
      lib/Predis/Command/ListPushTailX.php
  40. 1 1
      lib/Predis/Command/ListRange.php
  41. 1 1
      lib/Predis/Command/ListRemove.php
  42. 1 1
      lib/Predis/Command/ListSet.php
  43. 1 1
      lib/Predis/Command/ListTrim.php
  44. 0 108
      lib/Predis/Command/PrefixHelpers.php
  45. 0 31
      lib/Predis/Command/PrefixableCommand.php
  46. 1 1
      lib/Predis/Command/PrefixableCommandInterface.php
  47. 317 2
      lib/Predis/Command/Processor/KeyPrefixProcessor.php
  48. 1 1
      lib/Predis/Command/PubSubPublish.php
  49. 1 9
      lib/Predis/Command/PubSubSubscribe.php
  50. 1 9
      lib/Predis/Command/PubSubUnsubscribe.php
  51. 1 15
      lib/Predis/Command/ServerEval.php
  52. 1 1
      lib/Predis/Command/SetAdd.php
  53. 1 1
      lib/Predis/Command/SetCardinality.php
  54. 1 9
      lib/Predis/Command/SetIntersection.php
  55. 1 9
      lib/Predis/Command/SetIntersectionStore.php
  56. 1 1
      lib/Predis/Command/SetIsMember.php
  57. 1 1
      lib/Predis/Command/SetMembers.php
  58. 1 9
      lib/Predis/Command/SetMove.php
  59. 1 1
      lib/Predis/Command/SetPop.php
  60. 1 1
      lib/Predis/Command/SetRandomMember.php
  61. 1 1
      lib/Predis/Command/SetRemove.php
  62. 1 1
      lib/Predis/Command/SetScan.php
  63. 1 1
      lib/Predis/Command/StringAppend.php
  64. 1 1
      lib/Predis/Command/StringBitCount.php
  65. 1 9
      lib/Predis/Command/StringBitOp.php
  66. 1 1
      lib/Predis/Command/StringDecrement.php
  67. 1 1
      lib/Predis/Command/StringDecrementBy.php
  68. 1 1
      lib/Predis/Command/StringGet.php
  69. 1 1
      lib/Predis/Command/StringGetBit.php
  70. 1 9
      lib/Predis/Command/StringGetMultiple.php
  71. 1 1
      lib/Predis/Command/StringGetRange.php
  72. 1 1
      lib/Predis/Command/StringGetSet.php
  73. 1 1
      lib/Predis/Command/StringIncrement.php
  74. 1 1
      lib/Predis/Command/StringIncrementBy.php
  75. 1 1
      lib/Predis/Command/StringIncrementByFloat.php
  76. 1 1
      lib/Predis/Command/StringSet.php
  77. 1 1
      lib/Predis/Command/StringSetBit.php
  78. 1 1
      lib/Predis/Command/StringSetExpire.php
  79. 1 9
      lib/Predis/Command/StringSetMultiple.php
  80. 1 1
      lib/Predis/Command/StringSetPreserve.php
  81. 1 1
      lib/Predis/Command/StringSetRange.php
  82. 1 1
      lib/Predis/Command/StringStrlen.php
  83. 1 1
      lib/Predis/Command/StringSubstr.php
  84. 1 9
      lib/Predis/Command/TransactionWatch.php
  85. 1 1
      lib/Predis/Command/ZSetAdd.php
  86. 1 1
      lib/Predis/Command/ZSetCardinality.php
  87. 1 1
      lib/Predis/Command/ZSetCount.php
  88. 1 1
      lib/Predis/Command/ZSetIncrementBy.php
  89. 1 1
      lib/Predis/Command/ZSetRange.php
  90. 1 1
      lib/Predis/Command/ZSetRank.php
  91. 1 1
      lib/Predis/Command/ZSetRemove.php
  92. 1 1
      lib/Predis/Command/ZSetRemoveRangeByRank.php
  93. 1 1
      lib/Predis/Command/ZSetRemoveRangeByScore.php
  94. 1 1
      lib/Predis/Command/ZSetReverseRank.php
  95. 1 1
      lib/Predis/Command/ZSetScan.php
  96. 1 1
      lib/Predis/Command/ZSetScore.php
  97. 1 18
      lib/Predis/Command/ZSetUnionStore.php
  98. 0 25
      tests/Predis/Command/HashDeleteTest.php
  99. 0 25
      tests/Predis/Command/HashExistsTest.php
  100. 0 25
      tests/Predis/Command/HashGetAllTest.php

+ 5 - 0
CHANGELOG.md

@@ -46,6 +46,11 @@ v0.9.0 (201x-xx-xx)
 - The profile factory code has been extrapolated from the abstract Redis profile
   class and it's now in `Predis\Profile\Factory`.
 
+- The key prefixing logic has been moved from command classes to the key prefix
+  processor. Developers can define or override handlers used to prefix keys, but
+  they can also define the needed logic in their command classes by implementing
+  `Predis\Command\PrefixableCommandInterface` just like before.
+
 
 v0.8.5 (2013-xx-xx)
 ===============================================================================

+ 1 - 1
lib/Predis/Command/HashDelete.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/hdel
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class HashDelete extends PrefixableCommand
+class HashDelete extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/HashExists.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/hexists
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class HashExists extends PrefixableCommand
+class HashExists extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/HashGet.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/hget
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class HashGet extends PrefixableCommand
+class HashGet extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/HashGetAll.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/hgetall
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class HashGetAll extends PrefixableCommand
+class HashGetAll extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/HashGetMultiple.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/hmget
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class HashGetMultiple extends PrefixableCommand
+class HashGetMultiple extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/HashIncrementBy.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/hincrby
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class HashIncrementBy extends PrefixableCommand
+class HashIncrementBy extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/HashIncrementByFloat.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/hincrbyfloat
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class HashIncrementByFloat extends PrefixableCommand
+class HashIncrementByFloat extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/HashKeys.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/hkeys
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class HashKeys extends PrefixableCommand
+class HashKeys extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/HashLength.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/hlen
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class HashLength extends PrefixableCommand
+class HashLength extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/HashScan.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/hscan
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class HashScan extends PrefixableCommand
+class HashScan extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/HashSet.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/hset
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class HashSet extends PrefixableCommand
+class HashSet extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/HashSetMultiple.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/hmset
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class HashSetMultiple extends PrefixableCommand
+class HashSetMultiple extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/HashSetPreserve.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/hsetnx
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class HashSetPreserve extends PrefixableCommand
+class HashSetPreserve extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/HashValues.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/hvals
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class HashValues extends PrefixableCommand
+class HashValues extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 9
lib/Predis/Command/KeyDelete.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/del
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class KeyDelete extends AbstractCommand implements PrefixableCommandInterface
+class KeyDelete extends AbstractCommand
 {
     /**
      * {@inheritdoc}
@@ -32,12 +32,4 @@ class KeyDelete extends AbstractCommand implements PrefixableCommandInterface
     {
         return self::normalizeArguments($arguments);
     }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function prefixKeys($prefix)
-    {
-        PrefixHelpers::all($this, $prefix);
-    }
 }

+ 1 - 1
lib/Predis/Command/KeyDump.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/dump
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class KeyDump extends PrefixableCommand
+class KeyDump extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/KeyExists.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/exists
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class KeyExists extends PrefixableCommand
+class KeyExists extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/KeyExpire.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/expire
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class KeyExpire extends PrefixableCommand
+class KeyExpire extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/KeyExpireAt.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/expireat
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class KeyExpireAt extends PrefixableCommand
+class KeyExpireAt extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/KeyKeys.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/keys
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class KeyKeys extends PrefixableCommand
+class KeyKeys extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/KeyMove.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/move
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class KeyMove extends PrefixableCommand
+class KeyMove extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/KeyPersist.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/persist
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class KeyPersist extends PrefixableCommand
+class KeyPersist extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 9
lib/Predis/Command/KeyRename.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/rename
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class KeyRename extends AbstractCommand implements PrefixableCommandInterface
+class KeyRename extends AbstractCommand
 {
     /**
      * {@inheritdoc}
@@ -24,12 +24,4 @@ class KeyRename extends AbstractCommand implements PrefixableCommandInterface
     {
         return 'RENAME';
     }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function prefixKeys($prefix)
-    {
-        PrefixHelpers::all($this, $prefix);
-    }
 }

+ 1 - 1
lib/Predis/Command/KeyRestore.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/restore
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class KeyRestore extends PrefixableCommand
+class KeyRestore extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 35
lib/Predis/Command/KeySort.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/sort
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class KeySort extends AbstractCommand implements PrefixableCommandInterface
+class KeySort extends AbstractCommand
 {
     /**
      * {@inheritdoc}
@@ -80,38 +80,4 @@ class KeySort extends AbstractCommand implements PrefixableCommandInterface
 
         return $query;
     }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function prefixKeys($prefix)
-    {
-        if ($arguments = $this->getArguments()) {
-            $arguments[0] = "$prefix{$arguments[0]}";
-
-            if (($count = count($arguments)) > 1) {
-                for ($i = 1; $i < $count; $i++) {
-                    switch ($arguments[$i]) {
-                        case 'BY':
-                        case 'STORE':
-                            $arguments[$i] = "$prefix{$arguments[++$i]}";
-                            break;
-
-                        case 'GET':
-                            $value = $arguments[++$i];
-                            if ($value !== '#') {
-                                $arguments[$i] = "$prefix$value";
-                            }
-                            break;
-
-                        case 'LIMIT';
-                            $i += 2;
-                            break;
-                    }
-                }
-            }
-
-            $this->setRawArguments($arguments);
-        }
-    }
 }

+ 1 - 1
lib/Predis/Command/KeyTimeToLive.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/ttl
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class KeyTimeToLive extends PrefixableCommand
+class KeyTimeToLive extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/KeyType.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/type
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class KeyType extends PrefixableCommand
+class KeyType extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/ListIndex.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/lindex
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class ListIndex extends PrefixableCommand
+class ListIndex extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/ListInsert.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/linsert
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class ListInsert extends PrefixableCommand
+class ListInsert extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/ListLength.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/llen
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class ListLength extends PrefixableCommand
+class ListLength extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/ListPopFirst.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/lpop
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class ListPopFirst extends PrefixableCommand
+class ListPopFirst extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 9
lib/Predis/Command/ListPopFirstBlocking.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/blpop
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class ListPopFirstBlocking extends AbstractCommand implements PrefixableCommandInterface
+class ListPopFirstBlocking extends AbstractCommand
 {
     /**
      * {@inheritdoc}
@@ -37,12 +37,4 @@ class ListPopFirstBlocking extends AbstractCommand implements PrefixableCommandI
 
         return $arguments;
     }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function prefixKeys($prefix)
-    {
-        PrefixHelpers::skipLast($this, $prefix);
-    }
 }

+ 1 - 1
lib/Predis/Command/ListPopLast.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/rpop
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class ListPopLast extends PrefixableCommand
+class ListPopLast extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 9
lib/Predis/Command/ListPopLastPushHead.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/rpoplpush
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class ListPopLastPushHead extends AbstractCommand implements PrefixableCommandInterface
+class ListPopLastPushHead extends AbstractCommand
 {
     /**
      * {@inheritdoc}
@@ -24,12 +24,4 @@ class ListPopLastPushHead extends AbstractCommand implements PrefixableCommandIn
     {
         return 'RPOPLPUSH';
     }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function prefixKeys($prefix)
-    {
-        PrefixHelpers::all($this, $prefix);
-    }
 }

+ 1 - 9
lib/Predis/Command/ListPopLastPushHeadBlocking.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/brpoplpush
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class ListPopLastPushHeadBlocking extends AbstractCommand implements PrefixableCommandInterface
+class ListPopLastPushHeadBlocking extends AbstractCommand
 {
     /**
      * {@inheritdoc}
@@ -24,12 +24,4 @@ class ListPopLastPushHeadBlocking extends AbstractCommand implements PrefixableC
     {
         return 'BRPOPLPUSH';
     }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function prefixKeys($prefix)
-    {
-        PrefixHelpers::skipLast($this, $prefix);
-    }
 }

+ 1 - 1
lib/Predis/Command/ListPushHeadX.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/lpushx
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class ListPushHeadX extends PrefixableCommand
+class ListPushHeadX extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/ListPushTail.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/rpush
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class ListPushTail extends PrefixableCommand
+class ListPushTail extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/ListPushTailX.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/rpushx
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class ListPushTailX extends PrefixableCommand
+class ListPushTailX extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/ListRange.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/lrange
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class ListRange extends PrefixableCommand
+class ListRange extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/ListRemove.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/lrem
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class ListRemove extends PrefixableCommand
+class ListRemove extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/ListSet.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/lset
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class ListSet extends PrefixableCommand
+class ListSet extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/ListTrim.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/ltrim
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class ListTrim extends PrefixableCommand
+class ListTrim extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 0 - 108
lib/Predis/Command/PrefixHelpers.php

@@ -1,108 +0,0 @@
-<?php
-
-/*
- * This file is part of the Predis package.
- *
- * (c) Daniele Alessandri <suppakilla@gmail.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Predis\Command;
-
-/**
- * Class that defines a few helpers method for prefixing keys.
- *
- * @author Daniele Alessandri <suppakilla@gmail.com>
- */
-class PrefixHelpers
-{
-    /**
-     * Applies the specified prefix only the first argument.
-     *
-     * @param CommandInterface $command Command instance.
-     * @param string $prefix Prefix string.
-     */
-    public static function first(CommandInterface $command, $prefix)
-    {
-        if ($arguments = $command->getArguments()) {
-            $arguments[0] = "$prefix{$arguments[0]}";
-            $command->setRawArguments($arguments);
-        }
-    }
-
-    /**
-     * Applies the specified prefix to all the arguments.
-     *
-     * @param CommandInterface $command Command instance.
-     * @param string $prefix Prefix string.
-     */
-    public static function all(CommandInterface $command, $prefix)
-    {
-        if ($arguments = $command->getArguments()) {
-            foreach ($arguments as &$key) {
-                $key = "$prefix$key";
-            }
-
-            $command->setRawArguments($arguments);
-        }
-    }
-
-    /**
-     * Applies the specified prefix only to even arguments in the list.
-     *
-     * @param CommandInterface $command Command instance.
-     * @param string $prefix Prefix string.
-     */
-    public static function interleaved(CommandInterface $command, $prefix)
-    {
-        if ($arguments = $command->getArguments()) {
-            $length = count($arguments);
-
-            for ($i = 0; $i < $length; $i += 2) {
-                $arguments[$i] = "$prefix{$arguments[$i]}";
-            }
-
-            $command->setRawArguments($arguments);
-        }
-    }
-
-    /**
-     * Applies the specified prefix to all the arguments but the first one.
-     *
-     * @param CommandInterface $command Command instance.
-     * @param string $prefix Prefix string.
-     */
-    public static function skipFirst(CommandInterface $command, $prefix)
-    {
-        if ($arguments = $command->getArguments()) {
-            $length = count($arguments);
-
-            for ($i = 1; $i < $length; $i++) {
-                $arguments[$i] = "$prefix{$arguments[$i]}";
-            }
-
-            $command->setRawArguments($arguments);
-        }
-    }
-
-    /**
-     * Applies the specified prefix to all the arguments but the last one.
-     *
-     * @param CommandInterface $command Command instance.
-     * @param string $prefix Prefix string.
-     */
-    public static function skipLast(CommandInterface $command, $prefix)
-    {
-        if ($arguments = $command->getArguments()) {
-            $length = count($arguments);
-
-            for ($i = 0; $i < $length - 1; $i++) {
-                $arguments[$i] = "$prefix{$arguments[$i]}";
-            }
-
-            $command->setRawArguments($arguments);
-        }
-    }
-}

+ 0 - 31
lib/Predis/Command/PrefixableCommand.php

@@ -1,31 +0,0 @@
-<?php
-
-/*
- * This file is part of the Predis package.
- *
- * (c) Daniele Alessandri <suppakilla@gmail.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Predis\Command;
-
-/**
- * Base class for Redis commands with prefixable keys.
- *
- * @author Daniele Alessandri <suppakilla@gmail.com>
- */
-abstract class PrefixableCommand extends AbstractCommand implements PrefixableCommandInterface
-{
-    /**
-     * {@inheritdoc}
-     */
-    public function prefixKeys($prefix)
-    {
-        if ($arguments = $this->getArguments()) {
-            $arguments[0] = "$prefix{$arguments[0]}";
-            $this->setRawArguments($arguments);
-        }
-    }
-}

+ 1 - 1
lib/Predis/Command/PrefixableCommandInterface.php

@@ -16,7 +16,7 @@ namespace Predis\Command;
  *
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-interface PrefixableCommandInterface
+interface PrefixableCommandInterface extends CommandInterface
 {
     /**
      * Prefixes all the keys found in the arguments of the command.

+ 317 - 2
lib/Predis/Command/Processor/KeyPrefixProcessor.php

@@ -23,13 +23,132 @@ use Predis\Command\PrefixableCommandInterface;
 class KeyPrefixProcessor implements CommandProcessorInterface
 {
     private $prefix;
+    private $commands;
 
     /**
      * @param string $prefix Prefix for the keys.
      */
     public function __construct($prefix)
     {
-        $this->setPrefix($prefix);
+        $this->prefix = $prefix;
+        $this->commands = array(
+            /* ---------------- Redis 1.2 ---------------- */
+            'EXISTS'                    => 'self::first',
+            'DEL'                       => 'self::all',
+            'TYPE'                      => 'self::first',
+            'KEYS'                      => 'self::first',
+            'RENAME'                    => 'self::all',
+            'RENAMENX'                  => 'self::all',
+            'EXPIRE'                    => 'self::first',
+            'EXPIREAT'                  => 'self::first',
+            'TTL'                       => 'self::first',
+            'MOVE'                      => 'self::first',
+            'SORT'                      => 'self::sort',
+            'DUMP'                      => 'self::first',
+            'RESTORE'                   => 'self::first',
+            'SET'                       => 'self::first',
+            'SETNX'                     => 'self::first',
+            'MSET'                      => 'self::interleaved',
+            'MSETNX'                    => 'self::interleaved',
+            'GET'                       => 'self::first',
+            'MGET'                      => 'self::all',
+            'GETSET'                    => 'self::first',
+            'INCR'                      => 'self::first',
+            'INCRBY'                    => 'self::first',
+            'DECR'                      => 'self::first',
+            'DECRBY'                    => 'self::first',
+            'RPUSH'                     => 'self::first',
+            'LPUSH'                     => 'self::first',
+            'LLEN'                      => 'self::first',
+            'LRANGE'                    => 'self::first',
+            'LTRIM'                     => 'self::first',
+            'LINDEX'                    => 'self::first',
+            'LSET'                      => 'self::first',
+            'LREM'                      => 'self::first',
+            'LPOP'                      => 'self::first',
+            'RPOP'                      => 'self::first',
+            'RPOPLPUSH'                 => 'self::all',
+            'SADD'                      => 'self::first',
+            'SREM'                      => 'self::first',
+            'SPOP'                      => 'self::first',
+            'SMOVE'                     => 'self::skipLast',
+            'SCARD'                     => 'self::first',
+            'SISMEMBER'                 => 'self::first',
+            'SINTER'                    => 'self::all',
+            'SINTERSTORE'               => 'self::all',
+            'SUNION'                    => 'self::all',
+            'SUNIONSTORE'               => 'self::all',
+            'SDIFF'                     => 'self::all',
+            'SDIFFSTORE'                => 'self::all',
+            'SMEMBERS'                  => 'self::first',
+            'SRANDMEMBER'               => 'self::first',
+            'ZADD'                      => 'self::first',
+            'ZINCRBY'                   => 'self::first',
+            'ZREM'                      => 'self::first',
+            'ZRANGE'                    => 'self::first',
+            'ZREVRANGE'                 => 'self::first',
+            'ZRANGEBYSCORE'             => 'self::first',
+            'ZCARD'                     => 'self::first',
+            'ZSCORE'                    => 'self::first',
+            'ZREMRANGEBYSCORE'          => 'self::first',
+            /* ---------------- Redis 2.0 ---------------- */
+            'SETEX'                     => 'self::first',
+            'APPEND'                    => 'self::first',
+            'SUBSTR'                    => 'self::first',
+            'BLPOP'                     => 'self::skipLast',
+            'BRPOP'                     => 'self::skipLast',
+            'ZUNIONSTORE'               => 'self::zsetStore',
+            'ZINTERSTORE'               => 'self::zsetStore',
+            'ZCOUNT'                    => 'self::first',
+            'ZRANK'                     => 'self::first',
+            'ZREVRANK'                  => 'self::first',
+            'ZREMRANGEBYRANK'           => 'self::first',
+            'HSET'                      => 'self::first',
+            'HSETNX'                    => 'self::first',
+            'HMSET'                     => 'self::first',
+            'HINCRBY'                   => 'self::first',
+            'HGET'                      => 'self::first',
+            'HMGET'                     => 'self::first',
+            'HDEL'                      => 'self::first',
+            'HEXISTS'                   => 'self::first',
+            'HLEN'                      => 'self::first',
+            'HKEYS'                     => 'self::first',
+            'HVALS'                     => 'self::first',
+            'HGETALL'                   => 'self::first',
+            'SUBSCRIBE'                 => 'self::all',
+            'UNSUBSCRIBE'               => 'self::all',
+            'PSUBSCRIBE'                => 'self::all',
+            'PUNSUBSCRIBE'              => 'self::all',
+            'PUBLISH'                   => 'self::first',
+            /* ---------------- Redis 2.2 ---------------- */
+            'PERSIST'                   => 'self::first',
+            'STRLEN'                    => 'self::first',
+            'SETRANGE'                  => 'self::first',
+            'GETRANGE'                  => 'self::first',
+            'SETBIT'                    => 'self::first',
+            'GETBIT'                    => 'self::first',
+            'RPUSHX'                    => 'self::first',
+            'LPUSHX'                    => 'self::first',
+            'LINSERT'                   => 'self::first',
+            'BRPOPLPUSH'                => 'self::skipLast',
+            'ZREVRANGEBYSCORE'          => 'self::first',
+            'WATCH'                     => 'self::all',
+            /* ---------------- Redis 2.6 ---------------- */
+            'PTTL'                      => 'self::first',
+            'PEXPIRE'                   => 'self::first',
+            'PEXPIREAT'                 => 'self::first',
+            'PSETEX'                    => 'self::first',
+            'INCRBYFLOAT'               => 'self::first',
+            'BITOP'                     => 'self::skipFirst',
+            'BITCOUNT'                  => 'self::first',
+            'HINCRBYFLOAT'              => 'self::first',
+            'EVAL'                      => 'self::evalKeys',
+            'EVALSHA'                   => 'self::evalKeys',
+            /* ---------------- Redis 2.8 ---------------- */
+            'SSCAN'                     => 'self::first',
+            'ZSCAN'                     => 'self::first',
+            'HSCAN'                     => 'self::first',
+        );
     }
 
     /**
@@ -57,9 +176,43 @@ class KeyPrefixProcessor implements CommandProcessorInterface
      */
     public function process(CommandInterface $command)
     {
-        if ($command instanceof PrefixableCommandInterface && $command->getArguments()) {
+        if ($command instanceof PrefixableCommandInterface) {
             $command->prefixKeys($this->prefix);
+        } else if (isset($this->commands[$commandID = strtoupper($command->getId())])) {
+            call_user_func($this->commands[$commandID], $command, $this->prefix);
+        }
+    }
+
+    /**
+     * Sets an handler for the specified command ID.
+     *
+     * The callback signature must have 2 parameters of the following types:
+     *
+     *   - Predis\Command\CommandInterface (command instance)
+     *   - String (prefix)
+     *
+     * When the callback argument is omitted or NULL, the previously
+     * associated handler for the specified command ID is removed.
+     *
+     * @param string $commandID The ID of the command to be handled.
+     * @param mixed $callback A valid callable object or NULL.
+     */
+    public function setCommandHandler($commandID, $callback = null)
+    {
+        $commandID = strtoupper($commandID);
+
+        if (!isset($callback)) {
+            unset($this->commands[$commandID]);
+            return;
+        }
+
+        if (!is_callable($callback)) {
+            throw new InvalidArgumentException(
+                "Callback must be a valid callable object or NULL"
+            );
         }
+
+        $this->commands[$commandID] = $callback;
     }
 
     /**
@@ -69,4 +222,166 @@ class KeyPrefixProcessor implements CommandProcessorInterface
     {
         return $this->getPrefix();
     }
+
+    /**
+     * Applies the specified prefix only the first argument.
+     *
+     * @param CommandInterface $command Command instance.
+     * @param string $prefix Prefix string.
+     */
+    public static function first(CommandInterface $command, $prefix)
+    {
+        if ($arguments = $command->getArguments()) {
+            $arguments[0] = "$prefix{$arguments[0]}";
+            $command->setRawArguments($arguments);
+        }
+    }
+
+    /**
+     * Applies the specified prefix to all the arguments.
+     *
+     * @param CommandInterface $command Command instance.
+     * @param string $prefix Prefix string.
+     */
+    public static function all(CommandInterface $command, $prefix)
+    {
+        if ($arguments = $command->getArguments()) {
+            foreach ($arguments as &$key) {
+                $key = "$prefix$key";
+            }
+
+            $command->setRawArguments($arguments);
+        }
+    }
+
+    /**
+     * Applies the specified prefix only to even arguments in the list.
+     *
+     * @param CommandInterface $command Command instance.
+     * @param string $prefix Prefix string.
+     */
+    public static function interleaved(CommandInterface $command, $prefix)
+    {
+        if ($arguments = $command->getArguments()) {
+            $length = count($arguments);
+
+            for ($i = 0; $i < $length; $i += 2) {
+                $arguments[$i] = "$prefix{$arguments[$i]}";
+            }
+
+            $command->setRawArguments($arguments);
+        }
+    }
+
+    /**
+     * Applies the specified prefix to all the arguments but the first one.
+     *
+     * @param CommandInterface $command Command instance.
+     * @param string $prefix Prefix string.
+     */
+    public static function skipFirst(CommandInterface $command, $prefix)
+    {
+        if ($arguments = $command->getArguments()) {
+            $length = count($arguments);
+
+            for ($i = 1; $i < $length; $i++) {
+                $arguments[$i] = "$prefix{$arguments[$i]}";
+            }
+
+            $command->setRawArguments($arguments);
+        }
+    }
+
+    /**
+     * Applies the specified prefix to all the arguments but the last one.
+     *
+     * @param CommandInterface $command Command instance.
+     * @param string $prefix Prefix string.
+     */
+    public static function skipLast(CommandInterface $command, $prefix)
+    {
+        if ($arguments = $command->getArguments()) {
+            $length = count($arguments);
+
+            for ($i = 0; $i < $length - 1; $i++) {
+                $arguments[$i] = "$prefix{$arguments[$i]}";
+            }
+
+            $command->setRawArguments($arguments);
+        }
+    }
+
+    /**
+     * Applies the specified prefix to the keys of a SORT command.
+     *
+     * @param CommandInterface $command Command instance.
+     * @param string $prefix Prefix string.
+     */
+    public static function sort(CommandInterface $command, $prefix)
+    {
+        if ($arguments = $command->getArguments()) {
+            $arguments[0] = "$prefix{$arguments[0]}";
+
+            if (($count = count($arguments)) > 1) {
+                for ($i = 1; $i < $count; $i++) {
+                    switch ($arguments[$i]) {
+                        case 'BY':
+                        case 'STORE':
+                            $arguments[$i] = "$prefix{$arguments[++$i]}";
+                            break;
+
+                        case 'GET':
+                            $value = $arguments[++$i];
+                            if ($value !== '#') {
+                                $arguments[$i] = "$prefix$value";
+                            }
+                            break;
+
+                        case 'LIMIT';
+                            $i += 2;
+                            break;
+                    }
+                }
+            }
+
+            $command->setRawArguments($arguments);
+        }
+    }
+
+    /**
+     * Applies the specified prefix to the keys of an EVAL-based command.
+     *
+     * @param CommandInterface $command Command instance.
+     * @param string $prefix Prefix string.
+     */
+    public static function evalKeys(CommandInterface $command, $prefix)
+    {
+        if ($arguments = $command->getArguments()) {
+            for ($i = 2; $i < $arguments[1] + 2; $i++) {
+                $arguments[$i] = "$prefix{$arguments[$i]}";
+            }
+
+            $command->setRawArguments($arguments);
+        }
+    }
+
+    /**
+     * Applies the specified prefix to the keys of Z[INTERSECTION|UNION]STORE.
+     *
+     * @param CommandInterface $command Command instance.
+     * @param string $prefix Prefix string.
+     */
+    public static function zsetStore(CommandInterface $command, $prefix)
+    {
+        if ($arguments = $command->getArguments()) {
+            $arguments[0] = "$prefix{$arguments[0]}";
+            $length = ((int) $arguments[1]) + 2;
+
+            for ($i = 2; $i < $length; $i++) {
+                $arguments[$i] = "$prefix{$arguments[$i]}";
+            }
+
+            $command->setRawArguments($arguments);
+        }
+    }
 }

+ 1 - 1
lib/Predis/Command/PubSubPublish.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/publish
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class PubSubPublish extends PrefixableCommand
+class PubSubPublish extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 9
lib/Predis/Command/PubSubSubscribe.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/subscribe
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class PubSubSubscribe extends AbstractCommand implements PrefixableCommandInterface
+class PubSubSubscribe extends AbstractCommand
 {
     /**
      * {@inheritdoc}
@@ -32,12 +32,4 @@ class PubSubSubscribe extends AbstractCommand implements PrefixableCommandInterf
     {
         return self::normalizeArguments($arguments);
     }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function prefixKeys($prefix)
-    {
-        PrefixHelpers::all($this, $prefix);
-    }
 }

+ 1 - 9
lib/Predis/Command/PubSubUnsubscribe.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/unsubscribe
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class PubSubUnsubscribe extends AbstractCommand implements PrefixableCommandInterface
+class PubSubUnsubscribe extends AbstractCommand
 {
     /**
      * {@inheritdoc}
@@ -32,12 +32,4 @@ class PubSubUnsubscribe extends AbstractCommand implements PrefixableCommandInte
     {
         return self::normalizeArguments($arguments);
     }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function prefixKeys($prefix)
-    {
-        PrefixHelpers::all($this, $prefix);
-    }
 }

+ 1 - 15
lib/Predis/Command/ServerEval.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/eval
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class ServerEval extends AbstractCommand implements PrefixableCommandInterface
+class ServerEval extends AbstractCommand
 {
     /**
      * {@inheritdoc}
@@ -25,20 +25,6 @@ class ServerEval extends AbstractCommand implements PrefixableCommandInterface
         return 'EVAL';
     }
 
-    /**
-     * {@inheritdoc}
-     */
-    public function prefixKeys($prefix)
-    {
-        if ($arguments = $this->getArguments()) {
-            for ($i = 2; $i < $arguments[1] + 2; $i++) {
-                $arguments[$i] = "$prefix{$arguments[$i]}";
-            }
-
-            $this->setRawArguments($arguments);
-        }
-    }
-
     /**
      * Calculates the SHA1 hash of the body of the script.
      *

+ 1 - 1
lib/Predis/Command/SetAdd.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/sadd
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class SetAdd extends PrefixableCommand
+class SetAdd extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/SetCardinality.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/scard
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class SetCardinality extends PrefixableCommand
+class SetCardinality extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 9
lib/Predis/Command/SetIntersection.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/sinter
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class SetIntersection extends AbstractCommand implements PrefixableCommandInterface
+class SetIntersection extends AbstractCommand
 {
     /**
      * {@inheritdoc}
@@ -32,12 +32,4 @@ class SetIntersection extends AbstractCommand implements PrefixableCommandInterf
     {
         return self::normalizeArguments($arguments);
     }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function prefixKeys($prefix)
-    {
-        PrefixHelpers::all($this, $prefix);
-    }
 }

+ 1 - 9
lib/Predis/Command/SetIntersectionStore.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/sinterstore
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class SetIntersectionStore extends AbstractCommand implements PrefixableCommandInterface
+class SetIntersectionStore extends AbstractCommand
 {
     /**
      * {@inheritdoc}
@@ -36,12 +36,4 @@ class SetIntersectionStore extends AbstractCommand implements PrefixableCommandI
 
         return $arguments;
     }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function prefixKeys($prefix)
-    {
-        PrefixHelpers::all($this, $prefix);
-    }
 }

+ 1 - 1
lib/Predis/Command/SetIsMember.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/sismember
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class SetIsMember extends PrefixableCommand
+class SetIsMember extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/SetMembers.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/smembers
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class SetMembers extends PrefixableCommand
+class SetMembers extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 9
lib/Predis/Command/SetMove.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/smove
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class SetMove extends AbstractCommand implements PrefixableCommandInterface
+class SetMove extends AbstractCommand
 {
     /**
      * {@inheritdoc}
@@ -25,14 +25,6 @@ class SetMove extends AbstractCommand implements PrefixableCommandInterface
         return 'SMOVE';
     }
 
-    /**
-     * {@inheritdoc}
-     */
-    public function prefixKeys($prefix)
-    {
-        PrefixHelpers::skipLast($this, $prefix);
-    }
-
     /**
      * {@inheritdoc}
      */

+ 1 - 1
lib/Predis/Command/SetPop.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/spop
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class SetPop extends PrefixableCommand
+class SetPop extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/SetRandomMember.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/srandmember
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class SetRandomMember extends PrefixableCommand
+class SetRandomMember extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/SetRemove.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/srem
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class SetRemove extends PrefixableCommand
+class SetRemove extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/SetScan.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/sscan
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class SetScan extends PrefixableCommand
+class SetScan extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/StringAppend.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/append
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class StringAppend extends PrefixableCommand
+class StringAppend extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/StringBitCount.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/bitcount
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class StringBitCount extends PrefixableCommand
+class StringBitCount extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 9
lib/Predis/Command/StringBitOp.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/bitop
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class StringBitOp extends AbstractCommand implements PrefixableCommandInterface
+class StringBitOp extends AbstractCommand
 {
     /**
      * {@inheritdoc}
@@ -38,12 +38,4 @@ class StringBitOp extends AbstractCommand implements PrefixableCommandInterface
 
         return $arguments;
     }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function prefixKeys($prefix)
-    {
-        PrefixHelpers::skipFirst($this, $prefix);
-    }
 }

+ 1 - 1
lib/Predis/Command/StringDecrement.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/decr
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class StringDecrement extends PrefixableCommand
+class StringDecrement extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/StringDecrementBy.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/decrby
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class StringDecrementBy extends PrefixableCommand
+class StringDecrementBy extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/StringGet.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/get
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class StringGet extends PrefixableCommand
+class StringGet extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/StringGetBit.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/getbit
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class StringGetBit extends PrefixableCommand
+class StringGetBit extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 9
lib/Predis/Command/StringGetMultiple.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/mget
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class StringGetMultiple extends AbstractCommand implements PrefixableCommandInterface
+class StringGetMultiple extends AbstractCommand
 {
     /**
      * {@inheritdoc}
@@ -32,12 +32,4 @@ class StringGetMultiple extends AbstractCommand implements PrefixableCommandInte
     {
         return self::normalizeArguments($arguments);
     }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function prefixKeys($prefix)
-    {
-        PrefixHelpers::all($this, $prefix);
-    }
 }

+ 1 - 1
lib/Predis/Command/StringGetRange.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/getrange
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class StringGetRange extends PrefixableCommand
+class StringGetRange extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/StringGetSet.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/getset
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class StringGetSet extends PrefixableCommand
+class StringGetSet extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/StringIncrement.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/incr
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class StringIncrement extends PrefixableCommand
+class StringIncrement extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/StringIncrementBy.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/incrby
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class StringIncrementBy extends PrefixableCommand
+class StringIncrementBy extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/StringIncrementByFloat.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/incrbyfloat
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class StringIncrementByFloat extends PrefixableCommand
+class StringIncrementByFloat extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/StringSet.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/set
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class StringSet extends PrefixableCommand
+class StringSet extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/StringSetBit.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/setbit
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class StringSetBit extends PrefixableCommand
+class StringSetBit extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/StringSetExpire.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/setex
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class StringSetExpire extends PrefixableCommand
+class StringSetExpire extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 9
lib/Predis/Command/StringSetMultiple.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/mset
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class StringSetMultiple extends AbstractCommand implements PrefixableCommandInterface
+class StringSetMultiple extends AbstractCommand
 {
     /**
      * {@inheritdoc}
@@ -44,12 +44,4 @@ class StringSetMultiple extends AbstractCommand implements PrefixableCommandInte
 
         return $arguments;
     }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function prefixKeys($prefix)
-    {
-        PrefixHelpers::interleaved($this, $prefix);
-    }
 }

+ 1 - 1
lib/Predis/Command/StringSetPreserve.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/setnx
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class StringSetPreserve extends PrefixableCommand
+class StringSetPreserve extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/StringSetRange.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/setrange
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class StringSetRange extends PrefixableCommand
+class StringSetRange extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/StringStrlen.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/strlen
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class StringStrlen extends PrefixableCommand
+class StringStrlen extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/StringSubstr.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/substr
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class StringSubstr extends PrefixableCommand
+class StringSubstr extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 9
lib/Predis/Command/TransactionWatch.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/watch
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class TransactionWatch extends AbstractCommand implements PrefixableCommandInterface
+class TransactionWatch extends AbstractCommand
 {
     /**
      * {@inheritdoc}
@@ -37,14 +37,6 @@ class TransactionWatch extends AbstractCommand implements PrefixableCommandInter
         return $arguments;
     }
 
-    /**
-     * {@inheritdoc}
-     */
-    public function prefixKeys($prefix)
-    {
-        PrefixHelpers::all($this, $prefix);
-    }
-
     /**
      * {@inheritdoc}
      */

+ 1 - 1
lib/Predis/Command/ZSetAdd.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/zadd
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class ZSetAdd extends PrefixableCommand
+class ZSetAdd extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/ZSetCardinality.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/zcard
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class ZSetCardinality extends PrefixableCommand
+class ZSetCardinality extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/ZSetCount.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/zcount
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class ZSetCount extends PrefixableCommand
+class ZSetCount extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/ZSetIncrementBy.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/zincrby
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class ZSetIncrementBy extends PrefixableCommand
+class ZSetIncrementBy extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/ZSetRange.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/zrange
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class ZSetRange extends PrefixableCommand
+class ZSetRange extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/ZSetRank.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/zrank
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class ZSetRank extends PrefixableCommand
+class ZSetRank extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/ZSetRemove.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/zrem
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class ZSetRemove extends PrefixableCommand
+class ZSetRemove extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/ZSetRemoveRangeByRank.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/zremrangebyrank
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class ZSetRemoveRangeByRank extends PrefixableCommand
+class ZSetRemoveRangeByRank extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/ZSetRemoveRangeByScore.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/zremrangebyscore
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class ZSetRemoveRangeByScore extends PrefixableCommand
+class ZSetRemoveRangeByScore extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/ZSetReverseRank.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/zrevrank
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class ZSetReverseRank extends PrefixableCommand
+class ZSetReverseRank extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/ZSetScan.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/zscan
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class ZSetScan extends PrefixableCommand
+class ZSetScan extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 1
lib/Predis/Command/ZSetScore.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/zscore
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class ZSetScore extends PrefixableCommand
+class ZSetScore extends AbstractCommand
 {
     /**
      * {@inheritdoc}

+ 1 - 18
lib/Predis/Command/ZSetUnionStore.php

@@ -15,7 +15,7 @@ namespace Predis\Command;
  * @link http://redis.io/commands/zunionstore
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class ZSetUnionStore extends PrefixableCommand
+class ZSetUnionStore extends AbstractCommand
 {
     /**
      * {@inheritdoc}
@@ -73,21 +73,4 @@ class ZSetUnionStore extends PrefixableCommand
 
         return $finalizedOpts;
     }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function prefixKeys($prefix)
-    {
-        if ($arguments = $this->getArguments()) {
-            $arguments[0] = "$prefix{$arguments[0]}";
-            $length = ((int) $arguments[1]) + 2;
-
-            for ($i = 2; $i < $length; $i++) {
-                $arguments[$i] = "$prefix{$arguments[$i]}";
-            }
-
-            $this->setRawArguments($arguments);
-        }
-    }
 }

+ 0 - 25
tests/Predis/Command/HashDeleteTest.php

@@ -71,31 +71,6 @@ class HashDeleteTest extends CommandTestCase
         $this->assertSame(1, $this->getCommand()->parseResponse(1));
     }
 
-    /**
-     * @group disconnected
-     */
-    public function testPrefixKeys()
-    {
-        $arguments = array('key', 'field1', 'field2', 'field3');
-        $expected = array('prefix:key', 'field1', 'field2', 'field3');
-
-        $command = $this->getCommandWithArgumentsArray($arguments);
-        $command->prefixKeys('prefix:');
-
-        $this->assertSame($expected, $command->getArguments());
-    }
-
-    /**
-     * @group disconnected
-     */
-    public function testPrefixKeysIgnoredOnEmptyArguments()
-    {
-        $command = $this->getCommand();
-        $command->prefixKeys('prefix:');
-
-        $this->assertSame(array(), $command->getArguments());
-    }
-
     /**
      * @group connected
      */

+ 0 - 25
tests/Predis/Command/HashExistsTest.php

@@ -60,31 +60,6 @@ class HashExistsTest extends CommandTestCase
         $this->assertTrue($command->parseResponse(1));
     }
 
-    /**
-     * @group disconnected
-     */
-    public function testPrefixKeys()
-    {
-        $arguments = array('key', 'field');
-        $expected = array('prefix:key', 'field');
-
-        $command = $this->getCommandWithArgumentsArray($arguments);
-        $command->prefixKeys('prefix:');
-
-        $this->assertSame($expected, $command->getArguments());
-    }
-
-    /**
-     * @group disconnected
-     */
-    public function testPrefixKeysIgnoredOnEmptyArguments()
-    {
-        $command = $this->getCommand();
-        $command->prefixKeys('prefix:');
-
-        $this->assertSame(array(), $command->getArguments());
-    }
-
     /**
      * @group connected
      */

+ 0 - 25
tests/Predis/Command/HashGetAllTest.php

@@ -62,31 +62,6 @@ class HashGetAllTest extends CommandTestCase
         $this->assertSame($expected, $command->parseResponse($raw));
     }
 
-    /**
-     * @group disconnected
-     */
-    public function testPrefixKeys()
-    {
-        $arguments = array('key');
-        $expected = array('prefix:key');
-
-        $command = $this->getCommandWithArgumentsArray($arguments);
-        $command->prefixKeys('prefix:');
-
-        $this->assertSame($expected, $command->getArguments());
-    }
-
-    /**
-     * @group disconnected
-     */
-    public function testPrefixKeysIgnoredOnEmptyArguments()
-    {
-        $command = $this->getCommand();
-        $command->prefixKeys('prefix:');
-
-        $this->assertSame(array(), $command->getArguments());
-    }
-
     /**
      * @group connected
      */

Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů