mirror of
https://github.com/predis/predis.git
synced 2026-10-29 07:06:26 +00:00
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:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user