'evalSha' is deprecated
opened this issue · comments
@umbri What's the logic you implemented? I guess you can just use eval
directly now?
It does implement the API, just not totally low-level.
@kelunik I understand that this is a feature, but for me I need that old evalSha(), as I say I have some old code that was ported from another language with a lot of tests and using old evalSha() all was fine, now I get error, I understand that I can rewrite it but I think there may be other one as me, I suggest to just mark it as @deprecated
and not trigger_error()
If you don't want to get deprecation warnings, you can exclude them in your error reporting setting or explicitly silence your call to evalSha
.
We could maybe talk about not deprecating it at all, but given that it newer worked correctly, I don't see a lot of advantage in that.
I am worry of this extra call for sha1()
https://github.com/amphp/redis/blob/master/lib/Redis.php#L1923
I am calling evalSha()
very often, 90% off all calls to Redis
We could optimize that and include a lookup cache.
<?php
$cache = [];
function bench(string $script) {
global $cache;
// version without cache: return \sha1($script);
if (isset($cache[$script])) {
return $cache[$script];
}
$sha1 = \sha1($script);
$cache[$script] = $sha1;
return $sha1;
}
$start = \microtime(true);
for ($i = 0; $i < 1000000; $i++) {
bench("foobar = foobar = foobar = foobar = foobar;");
}
var_dump(\microtime(true) - $start);
kelunik@kelunik ❯ ~ ❯ 18:12:25 ❯
$ php test.php # with cache
float(0.05865216255188)
kelunik@kelunik ❯ ~ ❯ 18:12:38 ❯
$ php test.php # without cache
float(0.33159995079041)
Closing, as https://github.com/amphp/redis/releases/tag/v0.3.3 has been released with a script cache.