Redis Command Cheatsheet
Interactive reference for Redis commands across all major data types. Each command shows syntax, description, a practical example, and time complexity. Search or filter by category to find the right command fast.
Frequently Asked Questions
What is Redis and what is it used for?▼
Redis (Remote Dictionary Server) is an in-memory data structure store used as a database, cache, and message broker. Its key strengths are sub-millisecond read/write performance and rich data types: strings, lists, hashes, sets, sorted sets, streams, and more. Common use cases include session storage, rate limiting, pub/sub messaging, leaderboards (sorted sets), job queues (lists), and full-page caching.
What is the difference between KEYS and SCAN?▼
KEYS pattern returns all matching keys in one blocking call. In production with millions of keys, KEYS can block the Redis server for seconds, causing timeouts. SCAN is the safe alternative — it iterates the keyspace in small batches (cursor-based) without blocking. Always use SCAN in production. SCAN returns a cursor and a batch of keys; repeat until cursor returns 0.
What does O(1) vs O(N) mean for Redis commands?▼
O(1) means the command takes constant time regardless of data size — it is always fast. O(N) means the time scales linearly with N (number of elements). For example, LRANGE with a list of 1 million items is O(N) and can be slow. In Redis, O(N) commands on large data structures are a common source of latency spikes. Always check complexity before using commands like KEYS, SMEMBERS, or HGETALL on large data.
What is the difference between EXPIRE and TTL?▼
EXPIRE key seconds sets a timeout on a key — Redis will automatically delete it after that many seconds. TTL key returns the remaining time-to-live in seconds (-1 means no expiry, -2 means the key does not exist). PEXPIRE and PTTL are the millisecond equivalents. Use PERSIST to remove an expiry and make a key permanent again.
Related Products
on GumroadPremium Workflow Pack
Production-grade workflows, architecture guides, and deployment scripts for teams that ship. 10 advanced CI/CD workflows (blue-green, canary, E2E, security), 5 architecture deep-dives, code review checklist, PR process guide, and 5 battle-tested Bash deployment scripts.
Buy on Gumroad →DevPlaybook Interview Vault
210+ real technical interview questions with model answers, asked at Google, Meta, Amazon, Microsoft, Stripe, and Shopify. Covers Frontend (55), Backend (55), System Design (50), and DSA (50). Available in English and Traditional Chinese.
Buy on Gumroad →GitHub Actions CI/CD Templates Pack
12 production-ready GitHub Actions workflow templates covering Node.js, Python, Docker, multi-environment deployments, security scanning, and auto-changelog. Copy, paste, ship.
Buy on Gumroad →You Might Also Need
Redis Command Tester
Test Redis commands in your browser with no install needed. Simulate SET, GET, HSET, LPUSH, EXPIRE, TTL and more with color-coded output and a built-in command reference.
Open free tool →
Redis Pipeline Builder
Build Redis command pipelines visually. Add GET, SET, HSET, LPUSH, EXPIRE and other commands, reorder them, and export as raw pipeline, redis-cli, or Node.js ioredis code.
Open free tool →
Redis TTL Calculator
Calculate Redis cache expiration times. Generate EXPIRE, EXPIREAT, and SET EX commands. Includes jitter strategy for preventing cache stampede.
Open free tool →
More Free Tools
Related Articles
Redis vs Memcached vs Valkey: Caching Comparison 2026
Complete comparison of Redis, Memcached, and Valkey for caching in 2026. Covers data structures, persistence, clustering, memory management, use cases, performance benchmarks, and managed service pricing.
Redis Caching Patterns for Node.js: Cache-Aside, Write-Through, and TTL Strategies
Master Redis caching patterns in Node.js: cache-aside, write-through, write-behind, read-through, and TTL strategies. Code examples, when to use each pattern, and cache invalidation techniques.
Redis vs Memcached vs Dragonfly vs KeyDB: Caching Solutions 2025
In-depth comparison of Redis, Memcached, Dragonfly, and KeyDB for 2025. Benchmarks, use cases, and a decision guide to pick the right caching layer for your stack.
Redis Caching Patterns for Node.js Applications
Master Redis caching in Node.js with practical patterns: cache-aside, write-through, cache invalidation, TTL strategies, pub/sub, and production-ready implementation with ioredis.
Redis Caching Strategies for Node.js Applications
Master Redis caching in Node.js. Learn Cache-Aside, Write-Through, and Write-Back patterns with practical code examples, TTL strategies, and cache invalidation techniques.
Enjoying this tool? Get more like it.
Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.
Unlock AI-Powered Dev Tools
- ⚡ AI Code Review, Doc Generator & SQL Builder
- ⚡ All premium templates & early access
- ⚡ Member discounts on Gumroad products
$9/mo after trial · Cancel anytime
Want the full toolkit?
Get DevPlaybook Pro
Every template, guide, boilerplate, and automation script in one bundle. 13 premium products — grab them all at once and save big.
MIT licensed · Instant download · No subscription
See what's included → Browse all deals →