diff --git a/lib/Predis/Commands/Auth.php b/lib/Predis/Commands/Auth.php index 9c09580b..966382d2 100644 --- a/lib/Predis/Commands/Auth.php +++ b/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'; } } diff --git a/lib/Predis/Commands/BackgroundRewriteAppendOnlyFile.php b/lib/Predis/Commands/BackgroundRewriteAppendOnlyFile.php index 55ca89e2..61c10ad0 100644 --- a/lib/Predis/Commands/BackgroundRewriteAppendOnlyFile.php +++ b/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'; diff --git a/lib/Predis/Commands/BackgroundSave.php b/lib/Predis/Commands/BackgroundSave.php index c166d4fc..c65eb9f5 100644 --- a/lib/Predis/Commands/BackgroundSave.php +++ b/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') { diff --git a/lib/Predis/Commands/Command.php b/lib/Predis/Commands/Command.php index b5407370..ce904b70 100644 --- a/lib/Predis/Commands/Command.php +++ b/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 ($this->canBeHashed()) { + $key = $this->getHashablePart($this->_arguments[0]); + $this->_hash = $distributor->generateKey($key); + return $this->_hash; } - if (!isset($this->_arguments[0])) { - return null; - } - $key = $this->getHashablePart($this->_arguments[0]); - $this->_hash = $distributor->generateKey($key); - return $this->_hash; + return null; } protected function filterArguments(Array $arguments) { diff --git a/lib/Predis/Commands/Config.php b/lib/Predis/Commands/Config.php index 122d4fdf..2dde0c25 100644 --- a/lib/Predis/Commands/Config.php +++ b/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'; } } diff --git a/lib/Predis/Commands/DatabaseSize.php b/lib/Predis/Commands/DatabaseSize.php index 7a1e3aaf..b2c404c6 100644 --- a/lib/Predis/Commands/DatabaseSize.php +++ b/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'; } } diff --git a/lib/Predis/Commands/Discard.php b/lib/Predis/Commands/Discard.php index f73312ab..d0177cfd 100644 --- a/lib/Predis/Commands/Discard.php +++ b/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'; } } diff --git a/lib/Predis/Commands/DoEcho.php b/lib/Predis/Commands/DoEcho.php index a929d9c7..5caa4ec8 100644 --- a/lib/Predis/Commands/DoEcho.php +++ b/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'; } } diff --git a/lib/Predis/Commands/Exec.php b/lib/Predis/Commands/Exec.php index 7bef7edd..99e6a851 100644 --- a/lib/Predis/Commands/Exec.php +++ b/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'; } } diff --git a/lib/Predis/Commands/FlushAll.php b/lib/Predis/Commands/FlushAll.php index c9a97317..1eb6bd61 100644 --- a/lib/Predis/Commands/FlushAll.php +++ b/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'; } } diff --git a/lib/Predis/Commands/FlushDatabase.php b/lib/Predis/Commands/FlushDatabase.php index 084d0647..448efb08 100644 --- a/lib/Predis/Commands/FlushDatabase.php +++ b/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'; } } diff --git a/lib/Predis/Commands/GetMultiple.php b/lib/Predis/Commands/GetMultiple.php index 212b5ab3..8a557ffc 100644 --- a/lib/Predis/Commands/GetMultiple.php +++ b/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); diff --git a/lib/Predis/Commands/ICommand.php b/lib/Predis/Commands/ICommand.php index 37440a1f..bdd6b835 100644 --- a/lib/Predis/Commands/ICommand.php +++ b/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(); diff --git a/lib/Predis/Commands/Info.php b/lib/Predis/Commands/Info.php index a495d8cc..a300e5a3 100644 --- a/lib/Predis/Commands/Info.php +++ b/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(); diff --git a/lib/Predis/Commands/InfoV24x.php b/lib/Predis/Commands/InfoV24x.php index a9eb2342..f27645e1 100644 --- a/lib/Predis/Commands/InfoV24x.php +++ b/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; diff --git a/lib/Predis/Commands/Keys.php b/lib/Predis/Commands/Keys.php index d7c8e5f3..339ba662 100644 --- a/lib/Predis/Commands/Keys.php +++ b/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'; } } diff --git a/lib/Predis/Commands/LastSave.php b/lib/Predis/Commands/LastSave.php index 46e7fe32..4f8a6638 100644 --- a/lib/Predis/Commands/LastSave.php +++ b/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'; } } diff --git a/lib/Predis/Commands/MoveKey.php b/lib/Predis/Commands/MoveKey.php index 833dd3de..b343dbc5 100644 --- a/lib/Predis/Commands/MoveKey.php +++ b/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; } } diff --git a/lib/Predis/Commands/Multi.php b/lib/Predis/Commands/Multi.php index 9e8d1fb5..4a4383e5 100644 --- a/lib/Predis/Commands/Multi.php +++ b/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'; } } diff --git a/lib/Predis/Commands/Ping.php b/lib/Predis/Commands/Ping.php index 0810a012..e6efd65e 100644 --- a/lib/Predis/Commands/Ping.php +++ b/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; diff --git a/lib/Predis/Commands/Publish.php b/lib/Predis/Commands/Publish.php index 5e1a437b..74f35639 100644 --- a/lib/Predis/Commands/Publish.php +++ b/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'; } } diff --git a/lib/Predis/Commands/Quit.php b/lib/Predis/Commands/Quit.php index cd86fa57..a53faa9f 100644 --- a/lib/Predis/Commands/Quit.php +++ b/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'; } } diff --git a/lib/Predis/Commands/RandomKey.php b/lib/Predis/Commands/RandomKey.php index 23ef952f..a8ec603c 100644 --- a/lib/Predis/Commands/RandomKey.php +++ b/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; } } diff --git a/lib/Predis/Commands/Rename.php b/lib/Predis/Commands/Rename.php index 1cd8ea03..f6a973cd 100644 --- a/lib/Predis/Commands/Rename.php +++ b/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'; } } diff --git a/lib/Predis/Commands/RenamePreserve.php b/lib/Predis/Commands/RenamePreserve.php index e6684bd8..f88e4190 100644 --- a/lib/Predis/Commands/RenamePreserve.php +++ b/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; } } diff --git a/lib/Predis/Commands/Save.php b/lib/Predis/Commands/Save.php index b10c1ebe..6d8f675f 100644 --- a/lib/Predis/Commands/Save.php +++ b/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'; } } diff --git a/lib/Predis/Commands/SelectDatabase.php b/lib/Predis/Commands/SelectDatabase.php index 851c4433..fa3b6785 100644 --- a/lib/Predis/Commands/SelectDatabase.php +++ b/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'; } } diff --git a/lib/Predis/Commands/SetIntersection.php b/lib/Predis/Commands/SetIntersection.php index 6cd7740a..e2484665 100644 --- a/lib/Predis/Commands/SetIntersection.php +++ b/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); diff --git a/lib/Predis/Commands/SetIntersectionStore.php b/lib/Predis/Commands/SetIntersectionStore.php index dc0087a6..78ea568c 100644 --- a/lib/Predis/Commands/SetIntersectionStore.php +++ b/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); diff --git a/lib/Predis/Commands/SetMove.php b/lib/Predis/Commands/SetMove.php index f5d52d81..e5ed7748 100644 --- a/lib/Predis/Commands/SetMove.php +++ b/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; } } diff --git a/lib/Predis/Commands/SetMultiple.php b/lib/Predis/Commands/SetMultiple.php index 8a102d81..f26977ff 100644 --- a/lib/Predis/Commands/SetMultiple.php +++ b/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])) { diff --git a/lib/Predis/Commands/SetMultiplePreserve.php b/lib/Predis/Commands/SetMultiplePreserve.php index 5f5850df..d2d93677 100644 --- a/lib/Predis/Commands/SetMultiplePreserve.php +++ b/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; } } diff --git a/lib/Predis/Commands/Shutdown.php b/lib/Predis/Commands/Shutdown.php index e300357b..33e48807 100644 --- a/lib/Predis/Commands/Shutdown.php +++ b/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'; } } diff --git a/lib/Predis/Commands/SlaveOf.php b/lib/Predis/Commands/SlaveOf.php index 92697d77..2067baac 100644 --- a/lib/Predis/Commands/SlaveOf.php +++ b/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') { diff --git a/lib/Predis/Commands/Subscribe.php b/lib/Predis/Commands/Subscribe.php index 8122422a..0919cd4a 100644 --- a/lib/Predis/Commands/Subscribe.php +++ b/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'; } } diff --git a/lib/Predis/Commands/SubscribeByPattern.php b/lib/Predis/Commands/SubscribeByPattern.php index c1f17185..ac2fdf07 100644 --- a/lib/Predis/Commands/SubscribeByPattern.php +++ b/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'; } } diff --git a/lib/Predis/Commands/Unsubscribe.php b/lib/Predis/Commands/Unsubscribe.php index 7ee9ef40..ac854212 100644 --- a/lib/Predis/Commands/Unsubscribe.php +++ b/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'; } } diff --git a/lib/Predis/Commands/UnsubscribeByPattern.php b/lib/Predis/Commands/UnsubscribeByPattern.php index a3211b79..bc02da47 100644 --- a/lib/Predis/Commands/UnsubscribeByPattern.php +++ b/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'; } } diff --git a/lib/Predis/Commands/Unwatch.php b/lib/Predis/Commands/Unwatch.php index 1cdeb164..a476a169 100644 --- a/lib/Predis/Commands/Unwatch.php +++ b/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; } } diff --git a/lib/Predis/Commands/Watch.php b/lib/Predis/Commands/Watch.php index cc629ea0..a8c57c4c 100644 --- a/lib/Predis/Commands/Watch.php +++ b/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])) { diff --git a/lib/Predis/Commands/ZSetIntersectionStore.php b/lib/Predis/Commands/ZSetIntersectionStore.php index 11bc9e91..8e8b6a09 100644 --- a/lib/Predis/Commands/ZSetIntersectionStore.php +++ b/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'; } } diff --git a/lib/Predis/Commands/ZSetUnionStore.php b/lib/Predis/Commands/ZSetUnionStore.php index 790b79e1..aed60729 100644 --- a/lib/Predis/Commands/ZSetUnionStore.php +++ b/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();