Get ready for your next interview with our comprehensive question library
Redis supports several data types:
SET mykey "hello" # String
HSET user:1 name "John" # Hash
LPUSH mylist "item1" # List
SADD myset "member1" # Set
ZADD myzset 1 "item1" # Sorted Set
Aspect | Redis | Relational Database |
---|---|---|
Storage | In-memory | Disk-based |
Data Model | Key-value, NoSQL | Relational tables |
Schema | Schema-less | Fixed schema |
ACID | Limited ACID properties | Full ACID compliance |
Performance | Extremely fast (microseconds) | Slower (milliseconds) |
Persistence | Optional | Always persistent |
Query Language | Commands | SQL |
Relationships | No joins | Complex relationships |
Use Cases | Caching, sessions, real-time | Complex business logic |
Redis offers two persistence options:
RDB (Redis Database Backup):
AOF (Append Only File):
# RDB configuration
SAVE 900 1 # Save if at least 1 key changed in 900 seconds
SAVE 300 10 # Save if at least 10 keys changed in 300 seconds
# AOF configuration
appendonly yes
appendfsync everysec # Options: always, everysec, no
Upgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumAccess all premium content - interview questions, and other learning resources
We regularly update our features and content, to ensure you get the most relevant and updated premium content.
1000 monthly credits
Cancel anytime