Browse Source

Handle key prefixing in a completely different way.

When we will have PHP 5.4 going mainstream and Predis will drop support for
PHP 5.3, we will be able to rely in traits to semplify code and reuse more.
Daniele Alessandri 14 years ago
parent
commit
cad5d16eae
100 changed files with 207 additions and 325 deletions
  1. 0 26
      lib/Predis/Commands/Command.php
  2. 0 8
      lib/Predis/Commands/ConnectionAuth.php
  3. 0 8
      lib/Predis/Commands/ConnectionEcho.php
  4. 0 8
      lib/Predis/Commands/ConnectionPing.php
  5. 0 8
      lib/Predis/Commands/ConnectionQuit.php
  6. 0 8
      lib/Predis/Commands/ConnectionSelect.php
  7. 1 1
      lib/Predis/Commands/HashDelete.php
  8. 1 1
      lib/Predis/Commands/HashExists.php
  9. 1 1
      lib/Predis/Commands/HashGet.php
  10. 1 1
      lib/Predis/Commands/HashGetAll.php
  11. 1 1
      lib/Predis/Commands/HashGetMultiple.php
  12. 1 1
      lib/Predis/Commands/HashIncrementBy.php
  13. 1 1
      lib/Predis/Commands/HashIncrementByFloat.php
  14. 1 1
      lib/Predis/Commands/HashKeys.php
  15. 1 1
      lib/Predis/Commands/HashLength.php
  16. 1 1
      lib/Predis/Commands/HashSet.php
  17. 1 1
      lib/Predis/Commands/HashSetMultiple.php
  18. 1 1
      lib/Predis/Commands/HashSetPreserve.php
  19. 1 1
      lib/Predis/Commands/HashValues.php
  20. 0 7
      lib/Predis/Commands/ICommand.php
  21. 29 0
      lib/Predis/Commands/IPrefixable.php
  22. 3 3
      lib/Predis/Commands/KeyDelete.php
  23. 1 1
      lib/Predis/Commands/KeyExists.php
  24. 1 1
      lib/Predis/Commands/KeyExpire.php
  25. 1 1
      lib/Predis/Commands/KeyExpireAt.php
  26. 1 1
      lib/Predis/Commands/KeyKeys.php
  27. 1 1
      lib/Predis/Commands/KeyMove.php
  28. 1 1
      lib/Predis/Commands/KeyPersist.php
  29. 1 1
      lib/Predis/Commands/KeyRandom.php
  30. 3 3
      lib/Predis/Commands/KeyRename.php
  31. 4 3
      lib/Predis/Commands/KeySort.php
  32. 1 1
      lib/Predis/Commands/KeyTimeToLive.php
  33. 1 1
      lib/Predis/Commands/KeyType.php
  34. 1 1
      lib/Predis/Commands/ListIndex.php
  35. 1 1
      lib/Predis/Commands/ListInsert.php
  36. 1 1
      lib/Predis/Commands/ListLength.php
  37. 1 1
      lib/Predis/Commands/ListPopFirst.php
  38. 3 3
      lib/Predis/Commands/ListPopFirstBlocking.php
  39. 1 1
      lib/Predis/Commands/ListPopLast.php
  40. 3 3
      lib/Predis/Commands/ListPopLastPushHead.php
  41. 3 3
      lib/Predis/Commands/ListPopLastPushHeadBlocking.php
  42. 1 1
      lib/Predis/Commands/ListPushHeadX.php
  43. 1 1
      lib/Predis/Commands/ListPushTail.php
  44. 1 1
      lib/Predis/Commands/ListPushTailX.php
  45. 1 1
      lib/Predis/Commands/ListRange.php
  46. 1 1
      lib/Predis/Commands/ListRemove.php
  47. 1 1
      lib/Predis/Commands/ListSet.php
  48. 1 1
      lib/Predis/Commands/ListTrim.php
  49. 44 10
      lib/Predis/Commands/PrefixHelpers.php
  50. 30 0
      lib/Predis/Commands/PrefixableCommand.php
  51. 4 1
      lib/Predis/Commands/Processors/KeyPrefixProcessor.php
  52. 1 1
      lib/Predis/Commands/PubSubPublish.php
  53. 3 3
      lib/Predis/Commands/PubSubSubscribe.php
  54. 3 3
      lib/Predis/Commands/PubSubUnsubscribe.php
  55. 0 8
      lib/Predis/Commands/ServerBackgroundRewriteAOF.php
  56. 0 8
      lib/Predis/Commands/ServerBackgroundSave.php
  57. 0 8
      lib/Predis/Commands/ServerClient.php
  58. 0 8
      lib/Predis/Commands/ServerConfig.php
  59. 0 8
      lib/Predis/Commands/ServerDatabaseSize.php
  60. 2 2
      lib/Predis/Commands/ServerEval.php
  61. 0 8
      lib/Predis/Commands/ServerFlushAll.php
  62. 0 8
      lib/Predis/Commands/ServerFlushDatabase.php
  63. 0 8
      lib/Predis/Commands/ServerInfo.php
  64. 0 8
      lib/Predis/Commands/ServerLastSave.php
  65. 0 8
      lib/Predis/Commands/ServerMonitor.php
  66. 0 8
      lib/Predis/Commands/ServerObject.php
  67. 0 8
      lib/Predis/Commands/ServerSave.php
  68. 0 8
      lib/Predis/Commands/ServerScript.php
  69. 0 8
      lib/Predis/Commands/ServerShutdown.php
  70. 0 8
      lib/Predis/Commands/ServerSlaveOf.php
  71. 0 8
      lib/Predis/Commands/ServerSlowlog.php
  72. 1 1
      lib/Predis/Commands/SetAdd.php
  73. 1 1
      lib/Predis/Commands/SetCardinality.php
  74. 0 8
      lib/Predis/Commands/SetDifference.php
  75. 3 3
      lib/Predis/Commands/SetIntersection.php
  76. 3 3
      lib/Predis/Commands/SetIntersectionStore.php
  77. 1 1
      lib/Predis/Commands/SetIsMember.php
  78. 1 1
      lib/Predis/Commands/SetMembers.php
  79. 3 3
      lib/Predis/Commands/SetMove.php
  80. 1 1
      lib/Predis/Commands/SetPop.php
  81. 1 1
      lib/Predis/Commands/SetRandomMember.php
  82. 1 1
      lib/Predis/Commands/SetRemove.php
  83. 1 1
      lib/Predis/Commands/StringAppend.php
  84. 1 1
      lib/Predis/Commands/StringDecrement.php
  85. 1 1
      lib/Predis/Commands/StringDecrementBy.php
  86. 1 1
      lib/Predis/Commands/StringGet.php
  87. 1 1
      lib/Predis/Commands/StringGetBit.php
  88. 3 3
      lib/Predis/Commands/StringGetMultiple.php
  89. 1 1
      lib/Predis/Commands/StringGetRange.php
  90. 1 1
      lib/Predis/Commands/StringGetSet.php
  91. 1 1
      lib/Predis/Commands/StringIncrement.php
  92. 1 1
      lib/Predis/Commands/StringIncrementBy.php
  93. 1 1
      lib/Predis/Commands/StringIncrementByFloat.php
  94. 1 1
      lib/Predis/Commands/StringSet.php
  95. 1 1
      lib/Predis/Commands/StringSetBit.php
  96. 1 1
      lib/Predis/Commands/StringSetExpire.php
  97. 3 9
      lib/Predis/Commands/StringSetMultiple.php
  98. 1 1
      lib/Predis/Commands/StringSetPreserve.php
  99. 1 1
      lib/Predis/Commands/StringSetRange.php
  100. 1 1
      lib/Predis/Commands/StringStrlen.php

+ 0 - 26
lib/Predis/Commands/Command.php

@@ -75,32 +75,6 @@ abstract class Command implements ICommand
         }
     }
 
-    /**
-     * Implements the rule that is used to prefix the keys and returns a new
-     * array of arguments with the modified keys.
-     *
-     * @param array $arguments Arguments of the command.
-     * @param string $prefix Prefix appended to each key in the arguments.
-     * @return array
-     */
-    protected function onPrefixKeys(Array $arguments, $prefix)
-    {
-        $arguments[0] = "$prefix{$arguments[0]}";
-        return $arguments;
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function prefixKeys($prefix)
-    {
-        $arguments = $this->onPrefixKeys($this->arguments, $prefix);
-        if (isset($arguments)) {
-            $this->arguments = $arguments;
-            unset($this->hash);
-        }
-    }
-
     /**
      * Checks if the command can return an hash for client-side sharding.
      *

+ 0 - 8
lib/Predis/Commands/ConnectionAuth.php

@@ -25,14 +25,6 @@ class ConnectionAuth extends Command
         return 'AUTH';
     }
 
-    /**
-     * {@inheritdoc}
-     */
-    protected function onPrefixKeys(Array $arguments, $prefix)
-    {
-        /* NOOP */
-    }
-
     /**
      * {@inheritdoc}
      */

+ 0 - 8
lib/Predis/Commands/ConnectionEcho.php

@@ -25,14 +25,6 @@ class ConnectionEcho extends Command
         return 'ECHO';
     }
 
-    /**
-     * {@inheritdoc}
-     */
-    protected function onPrefixKeys(Array $arguments, $prefix)
-    {
-        /* NOOP */
-    }
-
     /**
      * {@inheritdoc}
      */

+ 0 - 8
lib/Predis/Commands/ConnectionPing.php

@@ -25,14 +25,6 @@ class ConnectionPing extends Command
         return 'PING';
     }
 
-    /**
-     * {@inheritdoc}
-     */
-    protected function onPrefixKeys(Array $arguments, $prefix)
-    {
-        /* NOOP */
-    }
-
     /**
      * {@inheritdoc}
      */

+ 0 - 8
lib/Predis/Commands/ConnectionQuit.php

@@ -25,14 +25,6 @@ class ConnectionQuit extends Command
         return 'QUIT';
     }
 
-    /**
-     * {@inheritdoc}
-     */
-    protected function onPrefixKeys(Array $arguments, $prefix)
-    {
-        /* NOOP */
-    }
-
     /**
      * {@inheritdoc}
      */

+ 0 - 8
lib/Predis/Commands/ConnectionSelect.php

@@ -25,14 +25,6 @@ class ConnectionSelect extends Command
         return 'SELECT';
     }
 
-    /**
-     * {@inheritdoc}
-     */
-    protected function onPrefixKeys(Array $arguments, $prefix)
-    {
-        /* NOOP */
-    }
-
     /**
      * {@inheritdoc}
      */

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

+ 0 - 7
lib/Predis/Commands/ICommand.php

@@ -49,13 +49,6 @@ interface ICommand
      */
     public function getArguments();
 
-    /**
-     * Prefixes all the keys in the arguments of the command.
-     *
-     * @param string $prefix String user to prefix the keys.
-     */
-    public function prefixKeys($prefix);
-
     /**
      * Parses a reply buffer and returns a PHP object.
      *

+ 29 - 0
lib/Predis/Commands/IPrefixable.php

@@ -0,0 +1,29 @@
+<?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\Commands;
+
+use Predis\Distribution\INodeKeyGenerator;
+
+/**
+ * Defines a command whose keys can be prefixed.
+ *
+ * @author Daniele Alessandri <suppakilla@gmail.com>
+ */
+interface IPrefixable
+{
+    /**
+     * Prefixes all the keys found in the arguments of the command.
+     *
+     * @param string $prefix String used to prefix the keys.
+     */
+    public function prefixKeys($prefix);
+}

+ 3 - 3
lib/Predis/Commands/KeyDelete.php

@@ -17,7 +17,7 @@ use Predis\Helpers;
  * @link http://redis.io/commands/del
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class KeyDelete extends Command
+class KeyDelete extends Command implements IPrefixable
 {
     /**
      * {@inheritdoc}
@@ -38,9 +38,9 @@ class KeyDelete extends Command
     /**
      * {@inheritdoc}
      */
-    protected function onPrefixKeys(Array $arguments, $prefix)
+    public function prefixKeys($prefix)
     {
-        return PrefixHelpers::multipleKeys($arguments, $prefix);
+        PrefixHelpers::all($this, $prefix);
     }
 
     /**

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

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

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

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

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

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

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

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

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

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

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

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

+ 1 - 1
lib/Predis/Commands/KeyRandom.php

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

+ 3 - 3
lib/Predis/Commands/KeyRename.php

@@ -15,7 +15,7 @@ namespace Predis\Commands;
  * @link http://redis.io/commands/rename
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class KeyRename extends Command
+class KeyRename extends Command implements IPrefixable
 {
     /**
      * {@inheritdoc}
@@ -28,9 +28,9 @@ class KeyRename extends Command
     /**
      * {@inheritdoc}
      */
-    protected function onPrefixKeys(Array $arguments, $prefix)
+    public function prefixKeys($prefix)
     {
-        return PrefixHelpers::multipleKeys($arguments, $prefix);
+        PrefixHelpers::all($this, $prefix);
     }
 
     /**

+ 4 - 3
lib/Predis/Commands/KeySort.php

@@ -15,7 +15,7 @@ namespace Predis\Commands;
  * @link http://redis.io/commands/sort
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class KeySort extends Command
+class KeySort extends Command implements IPrefixable
 {
     /**
      * {@inheritdoc}
@@ -83,8 +83,9 @@ class KeySort extends Command
     /**
      * {@inheritdoc}
      */
-    protected function onPrefixKeys(Array $arguments, $prefix)
+    public function prefixKeys($prefix)
     {
+        $arguments = $this->getArguments();
         $arguments[0] = "$prefix{$arguments[0]}";
 
         if (($count = count($arguments)) > 1) {
@@ -109,6 +110,6 @@ class KeySort extends Command
             }
         }
 
-        return $arguments;
+        $this->setRawArguments($arguments);
     }
 }

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

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

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

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

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

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

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

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

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

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

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

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

+ 3 - 3
lib/Predis/Commands/ListPopFirstBlocking.php

@@ -15,7 +15,7 @@ namespace Predis\Commands;
  * @link http://redis.io/commands/blpop
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class ListPopFirstBlocking extends Command
+class ListPopFirstBlocking extends Command implements IPrefixable
 {
     /**
      * {@inheritdoc}
@@ -28,9 +28,9 @@ class ListPopFirstBlocking extends Command
     /**
      * {@inheritdoc}
      */
-    protected function onPrefixKeys(Array $arguments, $prefix)
+    public function prefixKeys($prefix)
     {
-        return PrefixHelpers::skipLastArgument($arguments, $prefix);
+        PrefixHelpers::skipLast($this, $prefix);
     }
 
     /**

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

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

+ 3 - 3
lib/Predis/Commands/ListPopLastPushHead.php

@@ -15,7 +15,7 @@ namespace Predis\Commands;
  * @link http://redis.io/commands/rpoplpush
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class ListPopLastPushHead extends Command
+class ListPopLastPushHead extends Command implements IPrefixable
 {
     /**
      * {@inheritdoc}
@@ -28,9 +28,9 @@ class ListPopLastPushHead extends Command
     /**
      * {@inheritdoc}
      */
-    protected function onPrefixKeys(Array $arguments, $prefix)
+    public function prefixKeys($prefix)
     {
-        return PrefixHelpers::multipleKeys($arguments, $prefix);
+        PrefixHelpers::all($this, $prefix);
     }
 
     /**

+ 3 - 3
lib/Predis/Commands/ListPopLastPushHeadBlocking.php

@@ -15,7 +15,7 @@ namespace Predis\Commands;
  * @link http://redis.io/commands/brpoplpush
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class ListPopLastPushHeadBlocking extends Command
+class ListPopLastPushHeadBlocking extends Command implements IPrefixable
 {
     /**
      * {@inheritdoc}
@@ -28,9 +28,9 @@ class ListPopLastPushHeadBlocking extends Command
     /**
      * {@inheritdoc}
      */
-    protected function onPrefixKeys(Array $arguments, $prefix)
+    public function prefixKeys($prefix)
     {
-        return PrefixHelpers::skipLastArgument($arguments, $prefix);
+        PrefixHelpers::skipLast($this, $prefix);
     }
 
     /**

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

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

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

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

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

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

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

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

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

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

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

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

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

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

+ 44 - 10
lib/Predis/Commands/PrefixHelpers.php

@@ -18,36 +18,70 @@ namespace Predis\Commands;
  */
 class PrefixHelpers
 {
+    /**
+     * Applies the specified prefix only the first argument.
+     *
+     * @param ICommand $command Command instance.
+     * @param string $prefix Prefix string.
+     */
+    protected function first(ICommand $command, $prefix) {
+        $arguments = $command->getArguments();
+
+        $arguments[0] = "$prefix{$arguments[0]}";
+
+        $command->setRawArguments($arguments);
+    }
+
     /**
      * Applies the specified prefix to all the arguments.
      *
-     * @param array $arguments Array of arguments.
-     * @param string $prefix The prefix string.
-     * @return array
+     * @param ICommand $command Command instance.
+     * @param string $prefix Prefix string.
      */
-    public static function multipleKeys(Array $arguments, $prefix)
+    public static function all(ICommand $command, $prefix)
     {
+        $arguments = $command->getArguments();
+
         foreach ($arguments as &$key) {
             $key = "$prefix$key";
         }
 
-        return $arguments;
+        $command->setRawArguments($arguments);
+    }
+
+    /**
+     * Applies the specified prefix only to even arguments in the list.
+     *
+     * @param ICommand $command Command instance.
+     * @param string $prefix Prefix string.
+     */
+    public static function interleaved(ICommand $command, $prefix)
+    {
+        $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 last one.
      *
-     * @param array $arguments Array of arguments.
-     * @param string $prefix The prefix string.
-     * @return array
+     * @param ICommand $command Command instance.
+     * @param string $prefix Prefix string.
      */
-    public static function skipLastArgument(Array $arguments, $prefix)
+    public static function skipLast(ICommand $command, $prefix)
     {
+        $arguments = $command->getArguments();
         $length = count($arguments);
+
         for ($i = 0; $i < $length - 1; $i++) {
             $arguments[$i] = "$prefix{$arguments[$i]}";
         }
 
-        return $arguments;
+        $command->setRawArguments($arguments);
     }
 }

+ 30 - 0
lib/Predis/Commands/PrefixableCommand.php

@@ -0,0 +1,30 @@
+<?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\Commands;
+
+/**
+ * Base class for Redis commands with prefixable keys.
+ *
+ * @author Daniele Alessandri <suppakilla@gmail.com>
+ */
+abstract class PrefixableCommand extends Command implements IPrefixable
+{
+    /**
+     * {@inheritdoc}
+     */
+    public function prefixKeys($prefix)
+    {
+        $arguments = $this->getArguments();
+        $arguments[0] = "$prefix{$arguments[0]}";
+        $this->setRawArguments($arguments);
+    }
+}

+ 4 - 1
lib/Predis/Commands/Processors/KeyPrefixProcessor.php

@@ -12,6 +12,7 @@
 namespace Predis\Commands\Processors;
 
 use Predis\Commands\ICommand;
+use Predis\Commands\IPrefixable;
 
 /**
  * Command processor that is used to prefix the keys contained in the arguments
@@ -56,6 +57,8 @@ class KeyPrefixProcessor implements ICommandProcessor
      */
     public function process(ICommand $command)
     {
-        $command->prefixKeys($this->prefix);
+        if ($command instanceof IPrefixable) {
+            $command->prefixKeys($this->prefix);
+        }
     }
 }

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

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

+ 3 - 3
lib/Predis/Commands/PubSubSubscribe.php

@@ -17,7 +17,7 @@ use Predis\Helpers;
  * @link http://redis.io/commands/subscribe
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class PubSubSubscribe extends Command
+class PubSubSubscribe extends Command implements IPrefixable
 {
     /**
      * {@inheritdoc}
@@ -38,9 +38,9 @@ class PubSubSubscribe extends Command
     /**
      * {@inheritdoc}
      */
-    protected function onPrefixKeys(Array $arguments, $prefix)
+    public function prefixKeys($prefix)
     {
-        return PrefixHelpers::multipleKeys($arguments, $prefix);
+        PrefixHelpers::all($this, $prefix);
     }
 
     /**

+ 3 - 3
lib/Predis/Commands/PubSubUnsubscribe.php

@@ -15,7 +15,7 @@ namespace Predis\Commands;
  * @link http://redis.io/commands/unsubscribe
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class PubSubUnsubscribe extends Command
+class PubSubUnsubscribe extends Command implements IPrefixable
 {
     /**
      * {@inheritdoc}
@@ -28,9 +28,9 @@ class PubSubUnsubscribe extends Command
     /**
      * {@inheritdoc}
      */
-    protected function onPrefixKeys(Array $arguments, $prefix)
+    public function prefixKeys($prefix)
     {
-        return PrefixHelpers::multipleKeys($arguments, $prefix);
+        PrefixHelpers::all($this, $prefix);
     }
 
     /**

+ 0 - 8
lib/Predis/Commands/ServerBackgroundRewriteAOF.php

@@ -25,14 +25,6 @@ class ServerBackgroundRewriteAOF extends Command
         return 'BGREWRITEAOF';
     }
 
-    /**
-     * {@inheritdoc}
-     */
-    protected function onPrefixKeys(Array $arguments, $prefix)
-    {
-        /* NOOP */
-    }
-
     /**
      * {@inheritdoc}
      */

+ 0 - 8
lib/Predis/Commands/ServerBackgroundSave.php

@@ -25,14 +25,6 @@ class ServerBackgroundSave extends Command
         return 'BGSAVE';
     }
 
-    /**
-     * {@inheritdoc}
-     */
-    protected function onPrefixKeys(Array $arguments, $prefix)
-    {
-        /* NOOP */
-    }
-
     /**
      * {@inheritdoc}
      */

+ 0 - 8
lib/Predis/Commands/ServerClient.php

@@ -25,14 +25,6 @@ class ServerClient extends Command
         return 'CLIENT';
     }
 
-    /**
-     * {@inheritdoc}
-     */
-    protected function onPrefixKeys(Array $arguments, $prefix)
-    {
-        /* NOOP */
-    }
-
     /**
      * {@inheritdoc}
      */

+ 0 - 8
lib/Predis/Commands/ServerConfig.php

@@ -29,14 +29,6 @@ class ServerConfig extends Command
         return 'CONFIG';
     }
 
-    /**
-     * {@inheritdoc}
-     */
-    protected function onPrefixKeys(Array $arguments, $prefix)
-    {
-        /* NOOP */
-    }
-
     /**
      * {@inheritdoc}
      */

+ 0 - 8
lib/Predis/Commands/ServerDatabaseSize.php

@@ -25,14 +25,6 @@ class ServerDatabaseSize extends Command
         return 'DBSIZE';
     }
 
-    /**
-     * {@inheritdoc}
-     */
-    protected function onPrefixKeys(Array $arguments, $prefix)
-    {
-        /* NOOP */
-    }
-
     /**
      * {@inheritdoc}
      */

+ 2 - 2
lib/Predis/Commands/ServerEval.php

@@ -15,7 +15,7 @@ namespace Predis\Commands;
  * @link http://redis.io/commands/eval
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class ServerEval extends Command
+class ServerEval extends Command implements IPrefixable
 {
     /**
      * {@inheritdoc}
@@ -28,7 +28,7 @@ class ServerEval extends Command
     /**
      * {@inheritdoc}
      */
-    protected function onPrefixKeys(Array $arguments, $prefix)
+    public function prefixKeys($prefix)
     {
         $arguments = $this->getArguments();
 

+ 0 - 8
lib/Predis/Commands/ServerFlushAll.php

@@ -25,14 +25,6 @@ class ServerFlushAll extends Command
         return 'FLUSHALL';
     }
 
-    /**
-     * {@inheritdoc}
-     */
-    protected function onPrefixKeys(Array $arguments, $prefix)
-    {
-        /* NOOP */
-    }
-
     /**
      * {@inheritdoc}
      */

+ 0 - 8
lib/Predis/Commands/ServerFlushDatabase.php

@@ -25,14 +25,6 @@ class ServerFlushDatabase extends Command
         return 'FLUSHDB';
     }
 
-    /**
-     * {@inheritdoc}
-     */
-    protected function onPrefixKeys(Array $arguments, $prefix)
-    {
-        /* NOOP */
-    }
-
     /**
      * {@inheritdoc}
      */

+ 0 - 8
lib/Predis/Commands/ServerInfo.php

@@ -25,14 +25,6 @@ class ServerInfo extends Command
         return 'INFO';
     }
 
-    /**
-     * {@inheritdoc}
-     */
-    protected function onPrefixKeys(Array $arguments, $prefix)
-    {
-        /* NOOP */
-    }
-
     /**
      * {@inheritdoc}
      */

+ 0 - 8
lib/Predis/Commands/ServerLastSave.php

@@ -25,14 +25,6 @@ class ServerLastSave extends Command
         return 'LASTSAVE';
     }
 
-    /**
-     * {@inheritdoc}
-     */
-    protected function onPrefixKeys(Array $arguments, $prefix)
-    {
-        /* NOOP */
-    }
-
     /**
      * {@inheritdoc}
      */

+ 0 - 8
lib/Predis/Commands/ServerMonitor.php

@@ -25,14 +25,6 @@ class ServerMonitor extends Command
         return 'MONITOR';
     }
 
-    /**
-     * {@inheritdoc}
-     */
-    protected function onPrefixKeys(Array $arguments, $prefix)
-    {
-        /* NOOP */
-    }
-
     /**
      * {@inheritdoc}
      */

+ 0 - 8
lib/Predis/Commands/ServerObject.php

@@ -27,14 +27,6 @@ class ServerObject extends Command
         return 'OBJECT';
     }
 
-    /**
-     * {@inheritdoc}
-     */
-    protected function onPrefixKeys(Array $arguments, $prefix)
-    {
-        /* NOOP */
-    }
-
     /**
      * {@inheritdoc}
      */

+ 0 - 8
lib/Predis/Commands/ServerSave.php

@@ -25,14 +25,6 @@ class ServerSave extends Command
         return 'SAVE';
     }
 
-    /**
-     * {@inheritdoc}
-     */
-    protected function onPrefixKeys(Array $arguments, $prefix)
-    {
-        /* NOOP */
-    }
-
     /**
      * {@inheritdoc}
      */

+ 0 - 8
lib/Predis/Commands/ServerScript.php

@@ -25,14 +25,6 @@ class ServerScript extends Command
         return 'SCRIPT';
     }
 
-    /**
-     * {@inheritdoc}
-     */
-    protected function onPrefixKeys(Array $arguments, $prefix)
-    {
-        /* NOOP */
-    }
-
     /**
      * {@inheritdoc}
      */

+ 0 - 8
lib/Predis/Commands/ServerShutdown.php

@@ -25,14 +25,6 @@ class ServerShutdown extends Command
         return 'SHUTDOWN';
     }
 
-    /**
-     * {@inheritdoc}
-     */
-    protected function onPrefixKeys(Array $arguments, $prefix)
-    {
-        /* NOOP */
-    }
-
     /**
      * {@inheritdoc}
      */

+ 0 - 8
lib/Predis/Commands/ServerSlaveOf.php

@@ -37,14 +37,6 @@ class ServerSlaveOf extends Command
         return $arguments;
     }
 
-    /**
-     * {@inheritdoc}
-     */
-    protected function onPrefixKeys(Array $arguments, $prefix)
-    {
-        /* NOOP */
-    }
-
     /**
      * {@inheritdoc}
      */

+ 0 - 8
lib/Predis/Commands/ServerSlowlog.php

@@ -27,14 +27,6 @@ class ServerSlowlog extends Command
         return 'SLOWLOG';
     }
 
-    /**
-     * {@inheritdoc}
-     */
-    protected function onPrefixKeys(Array $arguments, $prefix)
-    {
-        /* NOOP */
-    }
-
     /**
      * {@inheritdoc}
      */

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

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

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

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

+ 0 - 8
lib/Predis/Commands/SetDifference.php

@@ -24,12 +24,4 @@ class SetDifference extends SetIntersection
     {
         return 'SDIFF';
     }
-
-    /**
-     * {@inheritdoc}
-     */
-    protected function onPrefixKeys(Array $arguments, $prefix)
-    {
-        return PrefixHelpers::multipleKeys($arguments, $prefix);
-    }
 }

+ 3 - 3
lib/Predis/Commands/SetIntersection.php

@@ -17,7 +17,7 @@ use Predis\Helpers;
  * @link http://redis.io/commands/sinter
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class SetIntersection extends Command
+class SetIntersection extends Command implements IPrefixable
 {
     /**
      * {@inheritdoc}
@@ -38,9 +38,9 @@ class SetIntersection extends Command
     /**
      * {@inheritdoc}
      */
-    protected function onPrefixKeys(Array $arguments, $prefix)
+    public function prefixKeys($prefix)
     {
-        return PrefixHelpers::multipleKeys($arguments, $prefix);
+        PrefixHelpers::all($this, $prefix);
     }
 
     /**

+ 3 - 3
lib/Predis/Commands/SetIntersectionStore.php

@@ -15,7 +15,7 @@ namespace Predis\Commands;
  * @link http://redis.io/commands/sinterstore
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class SetIntersectionStore extends Command
+class SetIntersectionStore extends Command implements IPrefixable
 {
     /**
      * {@inheritdoc}
@@ -40,9 +40,9 @@ class SetIntersectionStore extends Command
     /**
      * {@inheritdoc}
      */
-    protected function onPrefixKeys(Array $arguments, $prefix)
+    public function prefixKeys($prefix)
     {
-        return PrefixHelpers::multipleKeys($arguments, $prefix);
+        PrefixHelpers::all($this, $prefix);
     }
 
     /**

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

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

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

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

+ 3 - 3
lib/Predis/Commands/SetMove.php

@@ -15,7 +15,7 @@ namespace Predis\Commands;
  * @link http://redis.io/commands/smove
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class SetMove extends Command
+class SetMove extends Command implements IPrefixable
 {
     /**
      * {@inheritdoc}
@@ -28,9 +28,9 @@ class SetMove extends Command
     /**
      * {@inheritdoc}
      */
-    protected function onPrefixKeys(Array $arguments, $prefix)
+    public function prefixKeys($prefix)
     {
-        return PrefixHelpers::skipLastArgument($arguments, $prefix);
+        PrefixHelpers::skipLast($this, $prefix);
     }
 
     /**

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

+ 3 - 3
lib/Predis/Commands/StringGetMultiple.php

@@ -17,7 +17,7 @@ use Predis\Helpers;
  * @link http://redis.io/commands/mget
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class StringGetMultiple extends Command
+class StringGetMultiple extends Command implements IPrefixable
 {
     /**
      * {@inheritdoc}
@@ -38,9 +38,9 @@ class StringGetMultiple extends Command
     /**
      * {@inheritdoc}
      */
-    protected function onPrefixKeys(Array $arguments, $prefix)
+    public function prefixKeys($prefix)
     {
-        return PrefixHelpers::multipleKeys($arguments, $prefix);
+        PrefixHelpers::all($this, $prefix);
     }
 
     /**

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

+ 3 - 9
lib/Predis/Commands/StringSetMultiple.php

@@ -15,7 +15,7 @@ namespace Predis\Commands;
  * @link http://redis.io/commands/mset
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class StringSetMultiple extends Command
+class StringSetMultiple extends Command implements IPrefixable
 {
     /**
      * {@inheritdoc}
@@ -48,15 +48,9 @@ class StringSetMultiple extends Command
     /**
      * {@inheritdoc}
      */
-    protected function onPrefixKeys(Array $arguments, $prefix)
+    public function prefixKeys($prefix)
     {
-        $length = count($arguments);
-
-        for ($i = 0; $i < $length; $i += 2) {
-            $arguments[$i] = "$prefix{$arguments[$i]}";
-        }
-
-        return $arguments;
+        PrefixHelpers::interleaved($this, $prefix);
     }
 
     /**

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

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

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

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

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

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

Some files were not shown because too many files changed in this diff