Redis is an open-source, in-memory data structure store used as a database, cache, message broker, and streaming engine. Its speed and versatility make it essential for high-performance applications.
📑 Table of Contents
Key Features
- Data Structures: Strings, hashes, lists, sets, sorted sets
- Persistence: RDB snapshots and AOF logging
- Pub/Sub: Real-time messaging capabilities
- Clustering: Horizontal scaling support
- Lua Scripting: Server-side scripting
Installation
Install Redis on Ubuntu:
sudo apt update
sudo apt install redis-server
sudo systemctl enable redis-server
sudo systemctl start redis-server
Usage Examples
Basic Redis operations:
# Connect to Redis
redis-cli
# String operations
SET user:1:name "John"
GET user:1:name
# Hash operations
HSET user:1 name "John" email "john@example.com"
HGETALL user:1
# Set expiration
SETEX session:abc123 3600 "session_data"
Benefits
Redis provides sub-millisecond response times for caching and real-time applications. Its simple commands and rich data structures enable rapid development of high-performance systems.
Was this article helpful?