← All insightsCheat Sheet

Redis cheat sheet: the complete command reference

CodeWizard Engineering · 15 February 2026 · 3 min read · Beginner

This is a complete, hands-on Redis cheat sheet: install, configure, operate, automate and secure it - with copy-paste commands grouped by task. Bookmark it for day-to-day work, incidents and interviews alike.

Redis is an in-memory key-value store with rich data structures (strings, hashes, sorted sets, streams) used for caching, session storage, leaderboards, queues and rate limiting.

Why you reach for it

  • Sub-millisecond reads/writes for hot data
  • Versatile data structures beyond plain key-value
  • Built-in TTLs, pub/sub and streams

Installation

bash
docker run -d -p 6379:6379 redis:7
redis-cli ping   # -> PONG

Configuration reference

Cache-aside pattern and a simple rate limiter.

bash
# cache-aside with a 60s TTL
redis-cli SET user:42 '{...}' EX 60
redis-cli GET user:42
# fixed-window rate limit
redis-cli INCR rl:ip:1.2.3.4
redis-cli EXPIRE rl:ip:1.2.3.4 60

Core commands you use daily

bash
redis-cli --stat
redis-cli INFO memory
redis-cli SLOWLOG GET 10

Data structures

bash
SET user:42 '{...}' EX 60          # string with TTL
HSET cart:42 item1 2 item2 1        # hash
LPUSH queue job1                    # list
SADD tags redis devops              # set
ZADD board 100 alice 90 bob         # sorted set

Keyspace & admin

bash
TTL user:42
EXPIRE user:42 120
SCAN 0 MATCH 'user:*' COUNT 100     # never use KEYS in prod
INFO memory
CONFIG GET maxmemory-policy
SLOWLOG GET 10

Use it in CI/CD

Provide Redis as a service container in CI.

yaml
services:
  redis:
    image: redis:7
    ports: ['6379:6379']

Best-practice checklist

  • Set an eviction policy (e.g. allkeys-lru) and TTLs on cache keys
  • Use SCAN instead of KEYS in production
  • Right-size memory and monitor fragmentation

Common pitfalls to avoid

  • Using Redis as a primary database without a persistence/backup plan
  • Unbounded keys with no TTL slowly eating all memory
  • Big O(N) commands (KEYS *) blocking the single-threaded server

Security quick wins

  • Require a password/ACLs and never expose Redis to the internet
  • Enable TLS and rename or disable dangerous commands

Works well with

  • Apache Kafka - A distributed event-streaming platform for high-throughput, durable, replayable message pipelines.
  • rabbitmq
  • Kubernetes - Declarative orchestration for containers at scale - self-healing, rolling updates and service discovery.
A cheat sheet is muscle memory on paper - keep it close until the commands live in your fingers.

Want senior help putting Redis to work - or a team bootcamp on it? CodeWizard runs Israel's largest DevOps community and embeds named senior engineers with a transparent hours log. Book a free consult or explore the Academy.

Like where this is going?

Get hands-on help from the engineers who write these posts.

Book a free consult