Client handles -NOSCRIPT falling back to EVAL for scripted commands.

Now Predis\Command\ScriptedCommand uses EVALSHA instead of EVAL internally
so that performances should be better since the client do not resend the
Lua script body on each call.

Plain EVALSHA commands are not affected and will return or throw the error.
This commit is contained in:
Daniele Alessandri
2012-04-28 08:42:58 +02:00
parent 75afe831b0
commit 2d0b30dac5
5 changed files with 62 additions and 7 deletions
+13 -2
View File
@@ -18,7 +18,7 @@ namespace Predis\Command;
* @link http://redis.io/commands/eval
* @author Daniele Alessandri <suppakilla@gmail.com>
*/
abstract class ScriptedCommand extends ServerEval
abstract class ScriptedCommand extends ServerEvalSHA
{
/**
* Gets the body of a Lua script.
@@ -67,6 +67,17 @@ abstract class ScriptedCommand extends ServerEval
$numkeys = count($arguments);
}
return array_merge(array($this->getScript(), $numkeys), $arguments);
return array_merge(array(sha1($this->getScript()), $numkeys), $arguments);
}
/**
* @return array
*/
public function getEvalArguments()
{
$arguments = $this->getArguments();
$arguments[0] = $this->getScript();
return $arguments;
}
}