0
0
Redisquery~10 mins

RDB snapshots (point-in-time) in Redis - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - RDB snapshots (point-in-time)
Start Redis Server
Data changes in memory
Trigger snapshot condition?
Create RDB file
Save point-in-time data
Continue accepting commands
Redis saves a snapshot of data at a specific time when certain conditions are met, storing it in an RDB file for point-in-time recovery.
Execution Sample
Redis
SAVE
SET key1 value1
SET key2 value2
SAVE
DEL key1
SAVE
Shows Redis saving snapshots before and after data changes to capture point-in-time states.
Execution Table
StepCommandMemory Data StateRDB Snapshot CreatedSnapshot Content
1SAVE{}Yes{} (empty)
2SET key1 value1{key1: value1}No{} (previous snapshot)
3SET key2 value2{key1: value1, key2: value2}No{} (previous snapshot)
4SAVESame as memoryYes{key1: value1, key2: value2}
5DEL key1{key2: value2}No{key1: value1, key2: value2}
6SAVESame as memoryYes{key2: value2}
7ENDN/AN/AN/A
💡 No more commands; snapshots capture data state at SAVE commands.
Variable Tracker
VariableStartAfter 1After 2After 3After 4After 5After 6Final
Memory Data{}{}{key1: value1}{key1: value1, key2: value2}{key1: value1, key2: value2}{key2: value2}{key2: value2}{key2: value2}
RDB Snapshot{}{}{}{}{key1: value1, key2: value2}{key1: value1, key2: value2}{key2: value2}{key2: value2}
Key Moments - 3 Insights
Why does the RDB snapshot not change immediately after SET commands?
Because Redis only saves snapshots when the SAVE command runs, not on every data change. See steps 2 and 3 in execution_table where memory changes but snapshot stays the same.
What does the snapshot represent at each SAVE?
It represents the exact data state in memory at the moment SAVE runs, capturing a point-in-time copy. See steps 1, 4, and 6 where snapshots reflect memory at those times.
Why is the snapshot still the old data after DEL before the next SAVE?
Because the snapshot file only updates on SAVE, so deleting keys in memory doesn't affect the snapshot until the next SAVE command. See step 5 vs step 6.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table at step 4, what data is saved in the RDB snapshot?
A{}
B{key2: value2}
C{key1: value1, key2: value2}
D{key1: value1}
💡 Hint
Check the 'Snapshot Content' column at step 4 in execution_table.
At which step does the snapshot first include key2?
AStep 2
BStep 4
CStep 3
DStep 6
💡 Hint
Look at when the RDB snapshot content changes to include key2 in execution_table.
If the DEL command was followed immediately by a SAVE, what would the snapshot contain?
A{key2: value2}
B{key1: value1, key2: value2}
C{}
D{key1: value1}
💡 Hint
Refer to step 5 and 6 in execution_table and variable_tracker for memory and snapshot states.
Concept Snapshot
RDB snapshots save Redis data at a specific time.
Triggered by SAVE or automatic conditions.
Snapshot files store point-in-time data.
Data changes in memory do not update snapshots until saved.
Useful for backups and recovery.
Full Transcript
Redis RDB snapshots capture the exact data state at a specific moment. When Redis runs the SAVE command, it writes the current in-memory data to a snapshot file. Data changes like SET or DEL commands update memory immediately but do not affect the snapshot until the next SAVE. This allows Redis to have point-in-time backups. The execution trace shows memory data changing step-by-step and snapshots created only when SAVE runs, reflecting the data at that time. This helps beginners understand how snapshots represent frozen moments of data, not live updates.