Skip to main content
Use SCRIPT LOAD to compile a script and put it in the server’s script cache without running it. The reply is the script’s SHA1 digest, which is what EVALSHA takes. Loading the same script twice is harmless and always yields the same digest, so applications typically load their scripts once at startup and then call them by digest. The cache is lost on restart and cleared by SCRIPT FLUSH, so keep the script source available and be ready to handle a NOSCRIPT error by loading it again. Shebang flags are part of the source, so they are fixed at load time and a change to them produces a different digest. This includes allow-key-locking, which opts the script out of the global lock and into locking only the keys passed in KEYS; see Key-Based Locking. Whether or not you set that flag, write the script so that every key it touches arrives through KEYS rather than being assembled from ARGV inside the script, since an undeclared key can force a disk read while the lock is held. See Dynamic Keys and Latency.

Syntax

Arguments

Response

The reply reports the result of the operation. Error replies have the same shape in RESP2 and RESP3 and are surfaced as exceptions by the SDKs below.
Client libraries often decode bulk strings, maps, sets, and numeric strings into language-native values. The table describes the Redis wire reply.

Examples

TCP examples use the TLS REDIS_URL from the Upstash console. REST examples use UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN.