w3resource

Redis Scripting: SCRIPT LOAD script

Redis SCRIPT LOAD Command

Redis SCRIPT LOAD command is used to load a script into the scripts cache, without executing it. After the specified command is loaded into the script cache it will be callable using EVALSHA with the correct SHA1 digest of the script. The script is guaranteed to stay in the script cache forever . The command works in the same way even if the script was already present in the script cache.

Here are some common uses and scenarios for the "SCRIPT LOAD" command:

  • Preload Scripts: Loads a Lua script into the script cache without executing it, preparing it for future execution with EVALSHA.
  • Performance Optimization: Reduces the overhead of transmitting the script body multiple times by allowing it to be loaded once and executed multiple times using its SHA1 hash.
  • Script Management: Facilitates better management of scripts by ensuring they are cached and ready for use, improving efficiency and organization.
  • Deployment Preparation: Prepares scripts in advance during deployment, ensuring they are available for immediate execution when needed.

Syntax:

SCRIPT LOAD script

Available since

2.6.0.

Return Value

Bulk string replies. This command returns the SHA1 digest of the script added into the script cache.

Return Value Type

String

Example:

redis 127.0.0.1:6379> SCRIPT LOAD "return 1"
"e0e1f9fabfc9d4800c877a703b823ac0578ff8db"

Previous: SCRIPT KILL
Next: Redis Connection AUTH



Become a Patron!

Follow us on Facebook and Twitter for latest update.

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-script-load-script.php