Redis Scripting: EVALSHA sha1 numkeys key [key ...] arg [arg ...]
Redis EVALSHA command
Redis EVALSHA command evaluates a script cached on the server side by its SHA1 digest. Scripts are cached on the server side using the SCRIPT LOAD command.
Here are some common uses and scenarios for the "EVALSHA" command:
- Execute Cached Scripts: Executes a Lua script based on its SHA1 hash, using a pre-cached version of the script for efficiency.
- Script Reuse: Allows reuse of previously executed scripts without needing to resend the entire script, improving performance.
- Performance Optimization: Reduces network overhead by referencing the script via its hash rather than transmitting the script body each time.
- Security: Enhances security by preventing the need to send the script's source code over the network, minimizing exposure to potentially sensitive logic.
- Script Management: Supports script management and versioning by using hashes to track different versions of scripts, simplifying script updates and maintenance.
Syntax:
EVALSHA sha1 numkeys key [key ...] arg [arg ...]
Available since
2.6.0.
Example:
redis 127.0.0.1:6379> EVALSHA "return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}" 2 key1 key2 first second 1) "key1" 2) "key2" 3) "first" 4) "second"
Previous:
EVAL
Next:
SCRIPT EXISTS
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/redis/redis-evalsha-sha1-numkeys-key.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics