0
0
Redisquery~10 mins

SET and GET commands in Redis - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - SET and GET commands
Start
SET key value
Store value in key
GET key
Retrieve value
Output value
End
The flow shows storing a value with SET, then retrieving it with GET, and finally outputting the stored value.
Execution Sample
Redis
SET name "Alice"
GET name
Stores the value "Alice" under the key "name" and then retrieves it.
Execution Table
StepCommandActionKeyValue StoredOutput
1SET name "Alice"Store valuename"Alice"OK
2GET nameRetrieve valuename"Alice""Alice"
3GET ageRetrieve valueagenull(nil)
💡 No more commands to execute.
Variable Tracker
VariableStartAfter Step 1After Step 2After Step 3
namenull"Alice""Alice""Alice"
agenullnullnullnull
Key Moments - 2 Insights
Why does GET return (nil) when the key does not exist?
GET returns (nil) because the key is not found in the database, as shown in step 3 of the execution_table where 'age' was never set.
What does SET command output after storing a value?
SET outputs 'OK' to confirm the value was stored successfully, as seen in step 1 of the execution_table.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the output of the SET command at step 1?
AOK
B"Alice"
C(nil)
DError
💡 Hint
Check the Output column in row for step 1 in execution_table.
At which step does GET return (nil) because the key does not exist?
AStep 1
BStep 2
CStep 3
DNone
💡 Hint
Look at the Output column in execution_table for step 3.
If we SET key 'age' to '30' after step 3, what will GET age return?
A(nil)
B"30"
COK
DError
💡 Hint
Refer to how SET stores values and GET retrieves them as shown in steps 1 and 2.
Concept Snapshot
SET key value - stores a value under a key
GET key - retrieves the value stored
If key does not exist, GET returns (nil)
SET returns OK on success
GET returns the stored value as a string
Full Transcript
This visual execution shows how Redis commands SET and GET work. First, SET stores a value under a key and returns OK. Then GET retrieves the value for that key. If the key does not exist, GET returns (nil). The variable tracker shows how keys and values change after each command. This helps beginners see exactly what happens step-by-step.