0
0
Redisquery~10 mins

EVAL command for Lua execution 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 Lua script that returns the value of key 'mykey'.

Redis
EVAL "return redis.call('GET', [1])" 1 mykey
Drag options to blanks, or click blank then click option'
Amykey"
Bmykey
C"mykey"
D'mykey'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the key name without quotes causes a syntax error.
Using mismatched quotes breaks the script.
2fill in blank
medium

Complete the code to run a Lua script that increments the value of key 'counter' by 1.

Redis
EVAL "return redis.call('INCR', [1])" 1 counter
Drag options to blanks, or click blank then click option'
Acounter'
Bcounter
C'counter'
D"counter"
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting quotes around the key name.
Using mismatched or incorrect quotes.
3fill in blank
hard

Fix the error in the Lua script that returns the length of the value stored at key 'data'.

Redis
EVAL "return string.len(redis.call('GET', [1]))" 1 data
Drag options to blanks, or click blank then click option'
A'data'
Bdata
C"data"
Ddata"
Attempts:
3 left
💡 Hint
Common Mistakes
Using unquoted key names causing syntax errors.
Mismatched quotes inside the script.
4fill in blank
hard

Fill all three blanks to run a Lua script that sets key 'name' to 'Alice' and returns the new value.

Redis
EVAL "redis.call([1], [2], [3]); return redis.call('GET', 'name')" 1 name
Drag options to blanks, or click blank then click option'
A'SET'
B'name'
C'Alice'
D'GET'
Attempts:
3 left
💡 Hint
Common Mistakes
Using unquoted command or key names.
Swapping the order of command and key.
5fill in blank
hard

Fill all three blanks to run a Lua script that sets key 'age' to 30 and returns the value as a number.

Redis
EVAL "redis.call([1], [2], [3]); return tonumber(redis.call('GET', 'age'))" 1 age
Drag options to blanks, or click blank then click option'
A'SET'
B'age'
C'30'
D'GET'
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting the value '30'.
Using wrong order of arguments.
Forgetting to convert the returned value to number.