4
Add expiry support
Build Redis from scratch
4 hours
Level 4 of 4
Implement TTL functionality with SET EX and EXPIRE commands
Objectives
Complete these objectives to finish this level
- Add expiry timestamps to stored values
- Implement SET with EX option
- Implement EXPIRE command
- Auto-expire keys on access
Test Cases
Your implementation should pass these tests
- SET with EX expires keys
- EXPIRE sets TTL on existing keys
- Expired keys return nil
Hints
- 💡 Store expiry time with each key
- 💡 Use system time for comparisons
- 💡 Clean up expired keys lazily
Challenge Progress
Level 4 of 4100%