Top Banner
← Back to Blog

Redis Cheat Sheet

Redis Cheat Sheet

Redis is one of the fastest in-memory databases used for caching, session storage, queues, real-time analytics and high-performance applications. This cheat sheet covers installation, commands, monitoring, persistence and optimization techniques.

In This Guide

✓ Redis Installation
✓ Basic Commands
✓ Key Management
✓ Expiration & TTL
✓ Persistence
✓ Monitoring
✓ Performance Tuning
✓ Troubleshooting

Install Redis

sudo apt update
sudo apt install redis-server -y
sudo systemctl start redis-server
sudo systemctl enable redis-server
sudo systemctl status redis-server

Connect To Redis

redis-cli
redis-cli -h localhost -p 6379

Basic Commands

PING
SET username cloudrevol
GET username
DEL username
EXISTS username
KEYS *

Expiration & TTL

SET session_id abc123 EX 3600
TTL session_id
EXPIRE session_id 600

Hash Commands

HSET user:1 name "John"
HGET user:1 name
HGETALL user:1

List Commands

LPUSH jobs task1
RPUSH jobs task2
LRANGE jobs 0 -1

Set Commands

SADD users user1
SMEMBERS users
SCARD users

Persistence

SAVE
BGSAVE
LASTSAVE

Backup Redis

cp /var/lib/redis/dump.rdb backup.rdb
tar -czvf redis-backup.tar.gz /var/lib/redis

Monitoring Commands

INFO
INFO memory
INFO stats
MONITOR
CLIENT LIST
DBSIZE

Memory Optimization

CONFIG GET maxmemory
CONFIG SET maxmemory 2gb
CONFIG SET maxmemory-policy allkeys-lru

Troubleshooting

redis-cli ping
redis-cli info memory
redis-cli slowlog get
sudo journalctl -u redis-server -f
sudo systemctl restart redis-server

Redis Security Best Practices

  • ✓ Enable Authentication
  • ✓ Restrict Public Access
  • ✓ Use Firewall Rules
  • ✓ Enable TLS/SSL
  • ✓ Monitor Connections
  • ✓ Regular Backups
  • ✓ Update Redis Frequently

CloudRevol Redis Optimization

CloudRevol optimizes Redis deployments for high-performance applications, caching layers, session management and enterprise workloads.

🚀 Memory Optimization
⚡ Cache Tuning
📈 Monitoring
🛡 Security Hardening
💾 Backup Strategy
🔄 High Availability

Need Help Optimizing Redis?

CloudRevol provides managed cloud hosting, Redis optimization, monitoring, security hardening, database tuning and expert support.