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
+5 -3
View File
@@ -19,6 +19,7 @@ use \PHPUnit_Framework_TestCase as StandardTestCase;
class ScriptedCommandTest extends StandardTestCase
{
const LUA_SCRIPT = 'return { KEYS[1], KEYS[2], ARGV[1], ARGV[2] }';
const LUA_SCRIPT_SHA1 = '6e07f61f502e36d123fe28523076af588f5c315e';
/**
* @group disconnected
@@ -36,7 +37,8 @@ class ScriptedCommandTest extends StandardTestCase
->will($this->returnValue(2));
$command->setArguments($arguments);
$this->assertSame(array_merge(array(self::LUA_SCRIPT, 2), $arguments), $command->getArguments());
$this->assertSame(array_merge(array(self::LUA_SCRIPT_SHA1, 2), $arguments), $command->getArguments());
}
/**
@@ -55,7 +57,7 @@ class ScriptedCommandTest extends StandardTestCase
->will($this->returnValue(-2));
$command->setArguments($arguments);
$this->assertSame(array_merge(array(self::LUA_SCRIPT, 2), $arguments), $command->getArguments());
$this->assertSame(array_merge(array(self::LUA_SCRIPT_SHA1, 2), $arguments), $command->getArguments());
}
/**
@@ -156,6 +158,6 @@ class ScriptedCommandTest extends StandardTestCase
->will($this->returnValue(2));
$command->setArguments($arguments);
$this->assertSame(sha1(self::LUA_SCRIPT), $command->getScriptHash());
$this->assertSame(self::LUA_SCRIPT_SHA1, $command->getScriptHash());
}
}