Search code examples
javaredisspring-data-redis

Is it possible to use EVAL SHA with spring-data redis?


Is it possible to use the Redis command EVAL SHA command with Spring-Data Redis?

We are successfully using EVAL with execute command: redisTemplate.execute(script, null, args);, but it seems to put great overhead to transfer script to the Redis server each time.

Is it possible to store the script once and run it based on its SHA, using Spring-Data Redis?


Solution

  • The default ScriptExecutor optimizes performance by retrieving the SHA1 of the script and attempting first to run evalsha, falling back to eval if the script is not yet present in the Redis script cache.

    see spring-data redis docs

    The case is that "when we have a master/slave configuration, even though i have installed the same script on both servers and call the master with evalsha, the master forwards the entire script to the slave with an eval command every time".

    see this thread