0
0
Redisquery~10 mins

EVALSHA for cached scripts in Redis - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to run a cached Lua script using its SHA1 hash.

Redis
redis.call('[1]', sha1, 0)
Drag options to blanks, or click blank then click option'
AEVAL
BEVALSHA
CSCRIPT LOAD
DGET
Attempts:
3 left
💡 Hint
Common Mistakes
Using EVAL instead of EVALSHA
Trying to use SCRIPT LOAD to run the script
Using GET which is unrelated
2fill in blank
medium

Complete the code to run a cached script with 2 keys and 1 argument.

Redis
redis.call('EVALSHA', sha1, [1], key1, key2, arg1)
Drag options to blanks, or click blank then click option'
A0
B1
C3
D2
Attempts:
3 left
💡 Hint
Common Mistakes
Counting arguments instead of keys
Using 3 instead of 2
Using 1 or 0 which is too few
3fill in blank
hard

Fix the error in the code to correctly run a cached script with no keys.

Redis
redis.call('EVALSHA', sha1, [1])
Drag options to blanks, or click blank then click option'
A0
B1
Cnil
Dnull
Attempts:
3 left
💡 Hint
Common Mistakes
Using 1 when no keys are passed
Using nil or null which are invalid in Redis commands
4fill in blank
hard

Fill both blanks to load a script and then run it using EVALSHA.

Redis
local sha1 = redis.call('[1]', script)
redis.call('[2]', sha1, 0)
Drag options to blanks, or click blank then click option'
ASCRIPT LOAD
BEVALSHA
CEVAL
DGET
Attempts:
3 left
💡 Hint
Common Mistakes
Using EVAL instead of SCRIPT LOAD to cache
Using SCRIPT LOAD instead of EVALSHA to run
Using GET which is unrelated
5fill in blank
hard

Fill all three blanks to load a script, then run it with 1 key and 2 arguments.

Redis
local sha1 = redis.call('[1]', script)
redis.call('[2]', sha1, [3], key1, arg1, arg2)
Drag options to blanks, or click blank then click option'
ASCRIPT LOAD
BEVALSHA
C1
D2
Attempts:
3 left
💡 Hint
Common Mistakes
Using 2 instead of 1 for number of keys
Using EVAL instead of EVALSHA to run
Using wrong commands to load script