ソースを参照

Remove Predis\ICommand::canBeHashed() as a public method required for command classes and reuse it internally to Predis\Command.

Daniele Alessandri 14 年 前
コミット
b84c84007f
42 ファイル変更45 行追加47 行削除
  1. 1 1
      lib/Predis/Commands/Auth.php
  2. 1 1
      lib/Predis/Commands/BackgroundRewriteAppendOnlyFile.php
  3. 1 1
      lib/Predis/Commands/BackgroundSave.php
  4. 7 10
      lib/Predis/Commands/Command.php
  5. 1 1
      lib/Predis/Commands/Config.php
  6. 1 1
      lib/Predis/Commands/DatabaseSize.php
  7. 1 1
      lib/Predis/Commands/Discard.php
  8. 1 1
      lib/Predis/Commands/DoEcho.php
  9. 1 1
      lib/Predis/Commands/Exec.php
  10. 1 1
      lib/Predis/Commands/FlushAll.php
  11. 1 1
      lib/Predis/Commands/FlushDatabase.php
  12. 1 1
      lib/Predis/Commands/GetMultiple.php
  13. 0 1
      lib/Predis/Commands/ICommand.php
  14. 1 1
      lib/Predis/Commands/Info.php
  15. 0 1
      lib/Predis/Commands/InfoV24x.php
  16. 1 1
      lib/Predis/Commands/Keys.php
  17. 1 1
      lib/Predis/Commands/LastSave.php
  18. 1 1
      lib/Predis/Commands/MoveKey.php
  19. 1 1
      lib/Predis/Commands/Multi.php
  20. 1 1
      lib/Predis/Commands/Ping.php
  21. 1 1
      lib/Predis/Commands/Publish.php
  22. 1 1
      lib/Predis/Commands/Quit.php
  23. 1 1
      lib/Predis/Commands/RandomKey.php
  24. 1 1
      lib/Predis/Commands/Rename.php
  25. 1 1
      lib/Predis/Commands/RenamePreserve.php
  26. 1 1
      lib/Predis/Commands/Save.php
  27. 1 1
      lib/Predis/Commands/SelectDatabase.php
  28. 1 0
      lib/Predis/Commands/SetIntersection.php
  29. 1 0
      lib/Predis/Commands/SetIntersectionStore.php
  30. 1 1
      lib/Predis/Commands/SetMove.php
  31. 1 1
      lib/Predis/Commands/SetMultiple.php
  32. 0 1
      lib/Predis/Commands/SetMultiplePreserve.php
  33. 1 1
      lib/Predis/Commands/Shutdown.php
  34. 1 1
      lib/Predis/Commands/SlaveOf.php
  35. 1 1
      lib/Predis/Commands/Subscribe.php
  36. 1 1
      lib/Predis/Commands/SubscribeByPattern.php
  37. 1 1
      lib/Predis/Commands/Unsubscribe.php
  38. 1 1
      lib/Predis/Commands/UnsubscribeByPattern.php
  39. 1 1
      lib/Predis/Commands/Unwatch.php
  40. 1 1
      lib/Predis/Commands/Watch.php
  41. 1 0
      lib/Predis/Commands/ZSetIntersectionStore.php
  42. 1 0
      lib/Predis/Commands/ZSetUnionStore.php

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

@@ -3,6 +3,6 @@
 namespace Predis\Commands;
 
 class Auth extends Command {
-    public function canBeHashed()  { return false; }
+    protected function canBeHashed() { return false; }
     public function getId() { return 'AUTH'; }
 }

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

@@ -3,7 +3,7 @@
 namespace Predis\Commands;
 
 class BackgroundRewriteAppendOnlyFile extends Command {
-    public function canBeHashed()  { return false; }
+    protected function canBeHashed() { return false; }
     public function getId() { return 'BGREWRITEAOF'; }
     public function parseResponse($data) {
         return $data == 'Background append only file rewriting started';

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

@@ -3,7 +3,7 @@
 namespace Predis\Commands;
 
 class BackgroundSave extends Command {
-    public function canBeHashed()  { return false; }
+    protected function canBeHashed() { return false; }
     public function getId() { return 'BGSAVE'; }
     public function parseResponse($data) {
         if ($data == 'Background saving started') {

+ 7 - 10
lib/Predis/Commands/Command.php

@@ -8,8 +8,8 @@ abstract class Command implements ICommand {
     private $_hash;
     private $_arguments = array();
 
-    public function canBeHashed() {
-        return true;
+    protected function canBeHashed() {
+        return isset($this->_arguments[0]);
     }
 
     protected function getHashablePart($key) {
@@ -27,15 +27,12 @@ abstract class Command implements ICommand {
         if (isset($this->_hash)) {
             return $this->_hash;
         }
-        if (!$this->canBeHashed()) {
-            return null;
-        }
-        if (!isset($this->_arguments[0])) {
-            return null;
+        if ($this->canBeHashed()) {
+            $key = $this->getHashablePart($this->_arguments[0]);
+            $this->_hash = $distributor->generateKey($key);
+            return $this->_hash;
         }
-        $key = $this->getHashablePart($this->_arguments[0]);
-        $this->_hash = $distributor->generateKey($key);
-        return $this->_hash;
+        return null;
     }
 
     protected function filterArguments(Array $arguments) {

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

@@ -3,6 +3,6 @@
 namespace Predis\Commands;
 
 class Config extends Command {
-    public function canBeHashed()  { return false; }
+    protected function canBeHashed() { return false; }
     public function getId() { return 'CONFIG'; }
 }

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

@@ -3,6 +3,6 @@
 namespace Predis\Commands;
 
 class DatabaseSize extends Command {
-    public function canBeHashed()  { return false; }
+    protected function canBeHashed() { return false; }
     public function getId() { return 'DBSIZE'; }
 }

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

@@ -3,6 +3,6 @@
 namespace Predis\Commands;
 
 class Discard extends Command {
-    public function canBeHashed()  { return false; }
+    protected function canBeHashed() { return false; }
     public function getId() { return 'DISCARD'; }
 }

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

@@ -3,6 +3,6 @@
 namespace Predis\Commands;
 
 class DoEcho extends Command {
-    public function canBeHashed()  { return false; }
+    protected function canBeHashed() { return false; }
     public function getId() { return 'ECHO'; }
 }

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

@@ -3,6 +3,6 @@
 namespace Predis\Commands;
 
 class Exec extends Command {
-    public function canBeHashed()  { return false; }
+    protected function canBeHashed() { return false; }
     public function getId() { return 'EXEC'; }
 }

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

@@ -3,6 +3,6 @@
 namespace Predis\Commands;
 
 class FlushAll extends Command {
-    public function canBeHashed()  { return false; }
+    protected function canBeHashed() { return false; }
     public function getId() { return 'FLUSHALL'; }
 }

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

@@ -3,6 +3,6 @@
 namespace Predis\Commands;
 
 class FlushDatabase extends Command {
-    public function canBeHashed()  { return false; }
+    protected function canBeHashed() { return false; }
     public function getId() { return 'FLUSHDB'; }
 }

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

@@ -5,7 +5,7 @@ namespace Predis\Commands;
 use Predis\Utils;
 
 class GetMultiple extends Command {
-    public function canBeHashed()  { return false; }
+    protected function canBeHashed() { return false; }
     public function getId() { return 'MGET'; }
     public function filterArguments(Array $arguments) {
         return Utils::filterArrayArguments($arguments);

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

@@ -6,7 +6,6 @@ use Predis\Distribution\IDistributionStrategy;
 
 interface ICommand {
     public function getId();
-    public function canBeHashed();
     public function getHash(IDistributionStrategy $distributor);
     public function setArgumentsArray(Array $arguments);
     public function getArguments();

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

@@ -3,7 +3,7 @@
 namespace Predis\Commands;
 
 class Info extends Command {
-    public function canBeHashed()  { return false; }
+    protected function canBeHashed() { return false; }
     public function getId() { return 'INFO'; }
     public function parseResponse($data) {
         $info      = array();

+ 0 - 1
lib/Predis/Commands/InfoV24x.php

@@ -3,7 +3,6 @@
 namespace Predis\Commands;
 
 class InfoV24x extends Info {
-    public function canBeHashed()  { return false; }
     public function parseResponse($data) {
         $info      = array();
         $current   = null;

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

@@ -3,6 +3,6 @@
 namespace Predis\Commands;
 
 class Keys extends Command {
-    public function canBeHashed()  { return false; }
+    protected function canBeHashed() { return false; }
     public function getId() { return 'KEYS'; }
 }

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

@@ -3,6 +3,6 @@
 namespace Predis\Commands;
 
 class LastSave extends Command {
-    public function canBeHashed()  { return false; }
+    protected function canBeHashed() { return false; }
     public function getId() { return 'LASTSAVE'; }
 }

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

@@ -3,7 +3,7 @@
 namespace Predis\Commands;
 
 class MoveKey extends Command {
-    public function canBeHashed()  { return false; }
+    protected function canBeHashed() { return false; }
     public function getId() { return 'MOVE'; }
     public function parseResponse($data) { return (bool) $data; }
 }

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

@@ -3,6 +3,6 @@
 namespace Predis\Commands;
 
 class Multi extends Command {
-    public function canBeHashed()  { return false; }
+    protected function canBeHashed() { return false; }
     public function getId() { return 'MULTI'; }
 }

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

@@ -3,7 +3,7 @@
 namespace Predis\Commands;
 
 class Ping extends Command {
-    public function canBeHashed()  { return false; }
+    protected function canBeHashed() { return false; }
     public function getId() { return 'PING'; }
     public function parseResponse($data) {
         return $data === 'PONG' ? true : false;

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

@@ -3,6 +3,6 @@
 namespace Predis\Commands;
 
 class Publish extends Command {
-    public function canBeHashed()  { return false; }
+    protected function canBeHashed() { return false; }
     public function getId() { return 'PUBLISH'; }
 }

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

@@ -3,6 +3,6 @@
 namespace Predis\Commands;
 
 class Quit extends Command {
-    public function canBeHashed()  { return false; }
+    protected function canBeHashed() { return false; }
     public function getId() { return 'QUIT'; }
 }

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

@@ -3,7 +3,7 @@
 namespace Predis\Commands;
 
 class RandomKey extends Command {
-    public function canBeHashed()  { return false; }
+    protected function canBeHashed() { return false; }
     public function getId() { return 'RANDOMKEY'; }
     public function parseResponse($data) { return $data !== '' ? $data : null; }
 }

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

@@ -3,6 +3,6 @@
 namespace Predis\Commands;
 
 class Rename extends Command {
-    public function canBeHashed()  { return false; }
+    protected function canBeHashed() { return false; }
     public function getId() { return 'RENAME'; }
 }

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

@@ -3,7 +3,7 @@
 namespace Predis\Commands;
 
 class RenamePreserve extends Command {
-    public function canBeHashed()  { return false; }
+    protected function canBeHashed() { return false; }
     public function getId() { return 'RENAMENX'; }
     public function parseResponse($data) { return (bool) $data; }
 }

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

@@ -3,6 +3,6 @@
 namespace Predis\Commands;
 
 class Save extends Command {
-    public function canBeHashed()  { return false; }
+    protected function canBeHashed() { return false; }
     public function getId() { return 'SAVE'; }
 }

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

@@ -3,6 +3,6 @@
 namespace Predis\Commands;
 
 class SelectDatabase extends Command {
-    public function canBeHashed()  { return false; }
+    protected function canBeHashed() { return false; }
     public function getId() { return 'SELECT'; }
 }

+ 1 - 0
lib/Predis/Commands/SetIntersection.php

@@ -5,6 +5,7 @@ namespace Predis\Commands;
 use Predis\Utils;
 
 class SetIntersection extends Command {
+    protected function canBeHashed() { return false; }
     public function getId() { return 'SINTER'; }
     public function filterArguments(Array $arguments) {
         return Utils::filterArrayArguments($arguments);

+ 1 - 0
lib/Predis/Commands/SetIntersectionStore.php

@@ -5,6 +5,7 @@ namespace Predis\Commands;
 use Predis\Utils;
 
 class SetIntersectionStore extends Command {
+    protected function canBeHashed() { return false; }
     public function getId() { return 'SINTERSTORE'; }
     public function filterArguments(Array $arguments) {
         return Utils::filterArrayArguments($arguments);

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

@@ -3,7 +3,7 @@
 namespace Predis\Commands;
 
 class SetMove extends Command {
-    public function canBeHashed()  { return false; }
+    protected function canBeHashed() { return false; }
     public function getId() { return 'SMOVE'; }
     public function parseResponse($data) { return (bool) $data; }
 }

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

@@ -3,7 +3,7 @@
 namespace Predis\Commands;
 
 class SetMultiple extends Command {
-    public function canBeHashed()  { return false; }
+    protected function canBeHashed() { return false; }
     public function getId() { return 'MSET'; }
     public function filterArguments(Array $arguments) {
         if (count($arguments) === 1 && is_array($arguments[0])) {

+ 0 - 1
lib/Predis/Commands/SetMultiplePreserve.php

@@ -3,7 +3,6 @@
 namespace Predis\Commands;
 
 class SetMultiplePreserve extends SetMultiple {
-    public function canBeHashed()  { return false; }
     public function getId() { return 'MSETNX'; }
     public function parseResponse($data) { return (bool) $data; }
 }

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

@@ -3,6 +3,6 @@
 namespace Predis\Commands;
 
 class Shutdown extends Command {
-    public function canBeHashed()  { return false; }
+    protected function canBeHashed() { return false; }
     public function getId() { return 'SHUTDOWN'; }
 }

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

@@ -3,7 +3,7 @@
 namespace Predis\Commands;
 
 class SlaveOf extends Command {
-    public function canBeHashed()  { return false; }
+    protected function canBeHashed() { return false; }
     public function getId() { return 'SLAVEOF'; }
     public function filterArguments(Array $arguments) {
         if (count($arguments) === 0 || $arguments[0] === 'NO ONE') {

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

@@ -3,6 +3,6 @@
 namespace Predis\Commands;
 
 class Subscribe extends Command {
-    public function canBeHashed()  { return false; }
+    protected function canBeHashed() { return false; }
     public function getId() { return 'SUBSCRIBE'; }
 }

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

@@ -3,6 +3,6 @@
 namespace Predis\Commands;
 
 class SubscribeByPattern extends Command {
-    public function canBeHashed()  { return false; }
+    protected function canBeHashed() { return false; }
     public function getId() { return 'PSUBSCRIBE'; }
 }

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

@@ -3,6 +3,6 @@
 namespace Predis\Commands;
 
 class Unsubscribe extends Command {
-    public function canBeHashed()  { return false; }
+    protected function canBeHashed() { return false; }
     public function getId() { return 'UNSUBSCRIBE'; }
 }

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

@@ -3,6 +3,6 @@
 namespace Predis\Commands;
 
 class UnsubscribeByPattern extends Command {
-    public function canBeHashed()  { return false; }
+    protected function canBeHashed() { return false; }
     public function getId() { return 'PUNSUBSCRIBE'; }
 }

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

@@ -3,7 +3,7 @@
 namespace Predis\Commands;
 
 class Unwatch extends Command {
-    public function canBeHashed()  { return false; }
+    protected function canBeHashed() { return false; }
     public function getId() { return 'UNWATCH'; }
     public function parseResponse($data) { return (bool) $data; }
 }

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

@@ -3,7 +3,7 @@
 namespace Predis\Commands;
 
 class Watch extends Command {
-    public function canBeHashed()  { return false; }
+    protected function canBeHashed() { return false; }
     public function getId() { return 'WATCH'; }
     public function filterArguments(Array $arguments) {
         if (isset($arguments[0]) && is_array($arguments[0])) {

+ 1 - 0
lib/Predis/Commands/ZSetIntersectionStore.php

@@ -3,5 +3,6 @@
 namespace Predis\Commands;
 
 class ZSetIntersectionStore extends ZSetUnionStore {
+    protected function canBeHashed() { return false; }
     public function getId() { return 'ZINTERSTORE'; }
 }

+ 1 - 0
lib/Predis/Commands/ZSetUnionStore.php

@@ -3,6 +3,7 @@
 namespace Predis\Commands;
 
 class ZSetUnionStore extends Command {
+    protected function canBeHashed() { return false; }
     public function getId() { return 'ZUNIONSTORE'; }
     public function filterArguments(Array $arguments) {
         $options = array();