Redis Cheatsheet

Senior Backend Engineer
Search for a command to run...

Senior Backend Engineer
No comments yet. Be the first to comment.
Data Structures 1. Arrays int[] arr = new int[10]; arr[1] = 34; arr[1] = 35; int i = arr[1]; int size = arr.length; // Fill array with a value Arrays.fill(arr, -1); // Sort Arrays.sort(arr); // Ascending Arrays.sort(arr, (a, b) -> b - a); // Desce...
InfluxDB 3 client: influxctl influxctl is the official command-line tool for managing and interacting with InfluxDB 3 clusters. Think of it as your Swiss Army knife for database setup, bucket management, and query execution. This cheatsheet gives you...
Here is an extended and fully annotated version of the Linux Cheatsheet blog in Markdown, with: Brief descriptions for each command An Advanced Topics section covering cron, systemd, firewalld, SELinux, and more Linux Cheat sheet System Informat...

1 Year on LeetCode: Lessons, Struggles, and Growth Exactly one year ago, I made a commitment — to open LeetCode daily, without excuses, and start solving problems that once made me uncomfortable. What started as a casual attempt to improve my DSA ski...

Git Cheatsheet – The Ultimate Guide Whether you're just getting started with Git or you're a seasoned developer, having a handy cheatsheet saves time and avoids Googling the same commands over and over again. This guide is organized into Basic, Inter...

$ brew install redis-cli
PING # Test connection, returns PONG
AUTH <password> # Authenticate with password
SELECT <db> # Switch to a specific database (default is 0)
DBSIZE # Get total number of keys in the current DB
FLUSHDB # Remove all keys from the current DB
FLUSHALL # Remove all keys from all DBs
KEYS <pattern> # Find keys matching a pattern (use with caution in production)
SCAN 0 MATCH <p> # Incrementally iterate keys (safer than KEYS)
TYPE <key> # Get data type of a key
TTL <key> # Get remaining time to live of a key
EXPIRE <key> <s> # Set a key’s expiration in seconds
PERSIST <key> # Remove the expiration from a key
SET <key> <val> # Set value
GET <key> # Get value
MSET k1 v1 k2 v2 # Set multiple keys
MGET k1 k2 # Get multiple keys
INCR <key> # Increment integer value
DECR <key> # Decrement integer value
APPEND <key> <val> # Append value to existing key
STRLEN <key> # Get length of value
HSET <key> <field> <val> # Set field in a hash
HGET <key> <field> # Get field value
HMSET <key> f1 v1 f2 v2 # Set multiple fields
HMGET <key> f1 f2 # Get multiple fields
HGETALL <key> # Get all fields and values
HDEL <key> <field> # Delete a field
HLEN <key> # Number of fields
HKEYS <key> # Get all field names
HVALS <key> # Get all values
HEXISTS <key> <field> # Check if field exists
LPUSH <key> <val> # Push value to head
RPUSH <key> <val> # Push value to tail
LPOP <key> # Remove and return first element
RPOP <key> # Remove and return last element
LRANGE <key> 0 -1 # Get all elements
LLEN <key> # Get list length
LINDEX <key> <i> # Get element at index
LREM <key> <count> <val> # Remove elements equal to value
LTRIM <key> <start> <end> # Keep a sublist
SADD <key> <val> # Add member
SREM <key> <val> # Remove member
SMEMBERS <key> # Get all members
SISMEMBER <key> <val> # Check if member exists
SCARD <key> # Get number of members
SINTER key1 key2 # Intersection
SUNION key1 key2 # Union
SDIFF key1 key2 # Difference
ZADD <key> <score> <val> # Add member with score
ZRANGE <key> 0 -1 # Get all members by score (lowest to highest)
ZREVRANGE <key> 0 -1 # Get all members (highest to lowest)
ZRANK <key> <val> # Get rank of member
ZREVRANK <key> <val> # Get reverse rank
ZSCORE <key> <val> # Get score of member
ZCARD <key> # Number of members
ZREM <key> <val> # Remove member
MULTI # Start transaction
EXEC # Execute transaction
DISCARD # Cancel transaction
WATCH <key> # Watch key for changes
UNWATCH # Stop watching keys
PUBLISH <chan> <msg> # Publish message
SUBSCRIBE <chan> # Subscribe to channel
PSUBSCRIBE <pattern> # Subscribe to channel pattern
UNSUBSCRIBE <chan> # Unsubscribe
SAVE # Save DB synchronously
BGSAVE # Save DB asynchronously
CONFIG GET <param> # Read config
CONFIG SET <param> <val> # Update config
INFO # Get server info
MONITOR # Stream all commands (debugging)
Replication: SLAVEOF host port (deprecated, use REPLICAOF)
Cluster: CLUSTER NODES, CLUSTER INFO
Security: Use ACL LIST, ACL SETUSER
Performance: Prefer SCAN over KEYS in production