Skip to main content

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.

✓ Strings, Lists, Hashes, Sets, Sorted Sets ✓ Keys & expiry commands ✓ O() time complexity for each command ✓ Searchable & filterable

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.

Share this tool: X / Twitter LinkedIn
✓ 60,000+ developers use DevPlaybook ★★★★★ 4.8 / 5 on Gumroad ✓ MIT licensed · Instant download ✓ No login required

Related Products

on Gumroad

You Might Also Need

More Free Tools

Enjoying this tool? Get more like it.

Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.

DevPlaybook Pro 7 days free

Unlock AI-Powered Dev Tools

  • ⚡ AI Code Review, Doc Generator & SQL Builder
  • ⚡ All premium templates & early access
  • ⚡ Member discounts on Gumroad products
Start Free Trial →

$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.

$79
$241 separately Save $162 (67% off)
Get DevPlaybook Pro — $79 →

MIT licensed · Instant download · No subscription

See what's included → Browse all deals →