What is Redis
In-memory data store
Redis is a high-performance open-source in-memory data store used as a database, cache, and message broker.
Data Structures
- Strings — simple strings and numbers
- Lists — linked lists
- Sets — unique unordered elements
- Sorted Sets — ordered sets with scores
- Hashes — key-value dictionaries
- Streams — event streams (event log)
Key Features
- Speed: 100,000+ operations per second
- Persistence: RDB snapshots and AOF logs
- Replication: master-slave, Redis Sentinel
- Clustering: Redis Cluster (sharding)
- Pub/Sub: publish and subscribe to messages
- Lua scripts: atomic transactions
Use Cases
- Caching — sessions, API responses, query results
- Task queues — background processing, job queues
- Rate Limiting — API request throttling
- Leaderboards — rankings and tops
- Real-time analytics — counters, metrics
- Geolocation — coordinate-based search
Commands
- SET/GET — working with strings
- LPUSH/RPOP — queues
- SADD/SMEMBERS — sets
- ZADD/ZRANGE — sorted sets
- HSET/HGET — hashes