Less code duplication please.

This commit is contained in:
Daniele Alessandri
2010-06-12 09:59:04 +02:00
parent 5ae476ee16
commit 371a7ad69b
+11 -11
View File
@@ -783,21 +783,12 @@ class MultiExecBlock {
private function checkCapabilities(Client $redisClient) {
$profile = $redisClient->getProfile();
$canMulti = $profile->supportsCommand('multi') &&
$profile->supportsCommand('exec') &&
$profile->supportsCommand('discard');
$canWatch = $profile->supportsCommand('watch') &&
$profile->supportsCommand('unwatch');
if ($canMulti === false) {
if ($profile->supportsCommands(array('multi', 'exec', 'discard')) === false) {
throw new \Predis\ClientException(
'The current profile does not support MULTI, EXEC and DISCARD commands'
);
}
$this->_supportsWatch = $canWatch;
$this->_supportsWatch = $profile->supportsCommands(array('watch', 'unwatch'));
}
private function isWatchSupported() {
@@ -1461,6 +1452,15 @@ abstract class RedisServerProfile {
return new $profile();
}
public function supportsCommands(Array $commands) {
foreach ($commands as $command) {
if ($this->supportsCommand($command) === false) {
return false;
}
}
return true;
}
public function supportsCommand($command) {
return isset($this->_registeredCommands[$command]);
}