Reading — step 1 of 3
RDB Snapshots
~1 min readAdvanced Features
RDB Persistence — Snapshot to Disk
Redis is an in-memory database, but it needs to survive restarts. RDB (Redis Database) snapshots are point-in-time dumps of all data.
How Real Redis Does It
BGSAVEforks the process (copy-on-write)- Child process serializes all keys to a binary
.rdbfile - On startup, Redis loads the
.rdbfile to restore state
The RDB format is compact and fast to load — Redis can restore millions of keys per second.
Trade-offs
- Pro: Compact file, fast restore, great for backups
- Con: You can lose data between snapshots (last save to crash)
- Real Redis also supports AOF for durability (next lesson)
Our Simplified Format
We use a text-based format (real RDB is binary):
KEY string name Alice
KEY list mylist a,b,c
KEY hash user name=Alice,age=30
KEY set myset a,b,c
What You'll Build
SAVE— serialize all data, output the snapshotRESTORE— load a snapshot back into memory- This is the foundation of Redis's durability story
Discussion
Ask a question, share an insight, or help someone who’s stuck.
Sign in to post a comment or reply.
Loading…