Coder Social home page Coder Social logo

'evalSha' is deprecated about redis HOT 7 CLOSED

amphp avatar amphp commented on September 21, 2024
'evalSha' is deprecated

from redis.

Comments (7)

kelunik avatar kelunik commented on September 21, 2024

@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.

from redis.

 avatar commented on September 21, 2024

@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()

from redis.

kelunik avatar kelunik commented on September 21, 2024

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.

from redis.

 avatar commented on September 21, 2024

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

from redis.

kelunik avatar kelunik commented on September 21, 2024

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)

from redis.

 avatar commented on September 21, 2024

#51

from redis.

kelunik avatar kelunik commented on September 21, 2024

Closing, as https://github.com/amphp/redis/releases/tag/v0.3.3 has been released with a script cache.

from redis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.