0
0
Redisquery~5 mins

EVALSHA for cached scripts in Redis - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the Redis command EVALSHA do?

EVALSHA runs a Lua script that is already cached in Redis using its SHA1 hash. It avoids sending the full script again.

Click to reveal answer
beginner
Why use EVALSHA instead of EVAL in Redis?

EVALSHA is faster because it runs a cached script by its hash, so you don't resend the whole script text every time.

Click to reveal answer
intermediate
What happens if you run EVALSHA with a SHA1 hash that Redis does not recognize?

Redis returns an error saying the script is not found. You must load the script first with SCRIPT LOAD or use EVAL to run it.

Click to reveal answer
beginner
How do you get the SHA1 hash of a Lua script to use with EVALSHA?

Use the Redis command SCRIPT LOAD <script>. It returns the SHA1 hash of the script.

Click to reveal answer
intermediate
What are the arguments passed to EVALSHA after the SHA1 hash?

First, the number of keys the script will access, then the keys themselves, followed by any additional arguments the script needs.

Click to reveal answer
What does EVALSHA require to run a script?
AThe SHA1 hash of a cached script
BThe full Lua script text
CThe script filename
DThe script execution time
If EVALSHA returns a 'NOSCRIPT' error, what should you do?
AUse <code>SCRIPT LOAD</code> to load the script or run <code>EVAL</code> first
BChange the script name
CRestart Redis server
DIncrease Redis memory
Which command returns the SHA1 hash of a Lua script in Redis?
ASCRIPT HASH
BSCRIPT LOAD
CEVALSHA
DSCRIPT GET
What is the first argument after the SHA1 hash in EVALSHA?
ANumber of arguments
BScript timeout
CNumber of keys the script will access
DScript version
Why is EVALSHA preferred over EVAL for repeated script execution?
AIt automatically updates scripts
BIt uses less memory
CIt supports more Lua features
DIt runs scripts faster by avoiding re-sending the script text
Explain how EVALSHA works in Redis and why it is useful.
Think about caching and script reuse.
You got /4 concepts.
    Describe the steps to run a Lua script repeatedly using EVALSHA in Redis.
    Consider script loading, running, and error handling.
    You got /4 concepts.