EXISTS key★1 if the key exists, else 0.TYPE key★Which structure this key holds.DEL key [key...]★Remove one or more keys, blocking.UNLINK keyLike DEL, but frees memory asynchronously.RENAME old newRename a key, overwriting the destination.KEYS patternavoid in prodBlocks the server while it scans everything.SCAN 0 MATCH user:* COUNT 100★Cursor-based, non-blocking key iteration.
EXPIRE key 3600★Key auto-deletes in N seconds.PEXPIRE key 5000Same, in milliseconds.TTL key★Seconds left — -1 no expiry, -2 gone.PERSIST keyRemove the expiry, make it permanent again.EXPIREAT key 1735689600Expire at a specific Unix timestamp.
SET key value★Set a value, overwrites any type.GET key★Retrieve the value.SET key value EX 3600★Set value + TTL atomically — the caching idiom.SET key value NX★Set only if absent — basis of a simple lock.MSET k1 v1 k2 v2Set multiple keys atomically — pair with MGET.INCR key · INCRBY key 5★Atomic counter increment; DECR/DECRBY too.APPEND key valueAppend text; creates the key if missing.STRLEN keyLength of the stored string.
LPUSH key v1 v2★Push onto the head (left).RPUSH key v1 v2★Push onto the tail (right).LPOP key · RPOP key★Remove & return from head / tail.LRANGE key 0 -1★Whole list, in order (0 to -1 = all).LLEN keyNumber of elements.LREM key 0 valueRemove all matching elements.BLPOP key 5Blocking pop — waits up to 5s for an item.
HSET key field value★Set one field on a hash.HGET key field★Read one field.HGETALL key★Every field-value pair on the hash.HMGET key f1 f2Multiple fields in one round trip.HDEL key fieldRemove one or more fields.HINCRBY key field 1Atomic increment on a single field.HKEYS key · HVALS keyJust the field names, or just the values.
SADD key m1 m2★Add members — duplicates are no-ops.SMEMBERS key★Every member of the set.SISMEMBER key member★Membership test, O(1).SREM key memberRemove one or more members.SCARD keyNumber of members.SINTER k1 k2 · SUNION · SDIFFSet algebra across multiple keys.SPOP keyRemove & return a random member.
ZADD key score member★Add/update a member with its score.ZRANGE key 0 -1 WITHSCORES★Members low-to-high by score.ZREVRANGE key 0 9 WITHSCORES★Top 10, high-to-low — classic leaderboard.ZSCORE key memberScore of one member.ZRANK key member0-based position, ascending order.ZINCRBY key 1 memberBump a member's score atomically.ZRANGEBYSCORE key 10 50Members whose score falls in a range.
SETBIT key 7 1Set a single bit at an offset.GETBIT key 7Read a single bit.BITCOUNT keyCount set (1) bits in the string.BITOP AND dest k1 k2Bitwise AND/OR/XOR/NOT across keys.PFADD key element★Add to a HyperLogLog, ~12KB regardless of size.PFCOUNT key★Approximate unique-element count (~0.8% error).
XADD key * field value★Append an entry; * auto-generates the ID.XLEN keyNumber of entries in the stream.XRANGE key - +★Entries between two IDs, - and + = all.XREAD COUNT 10 STREAMS key 0Read entries after a given ID.XGROUP CREATE key group 0Create a consumer group for fan-out processing.XACK key group idAcknowledge a message as processed.
GEOADD key lon lat member★Add a point by longitude/latitude.GEODIST key m1 m2 kmDistance between two members.GEOSEARCH key FROMMEMBER m BYRADIUS 5 km★Points within radius/box of a member or coords.
MULTI★Start queuing commands instead of running them.EXEC★Run every queued command atomically.DISCARDCancel the queued transaction.WATCH key★Optimistic lock — EXEC aborts if key changed.
SUBSCRIBE channel★Listen for messages on a channel.PUBLISH channel message★Send a message to every subscriber.PSUBSCRIBE news.*Subscribe to channels matching a pattern.UNSUBSCRIBE channelStop listening; no args = leave all channels.
SAVESynchronous snapshot — blocks the server.BGSAVE★Background snapshot, non-blocking.BGREWRITEAOFCompact the append-only file in the background.
REPLICAOF host port★Make this instance a replica of another.REPLICAOF NO ONEPromote a replica back to primary.WAIT 1 1000Block until N replicas ack, or timeout (ms).
CONFIG GET maxmemory-policyRead a live config parameter.CONFIG SET maxmemory 2gbChange config at runtime, no restart.
EVAL "return redis.call('GET', KEYS[1])" 1 key★Run a Lua script atomically.SCRIPT LOAD "..."Cache a script server-side, get back a SHA.EVALSHA sha 1 keyRun a previously cached script by its SHA.
FLUSHDB ASYNCdestroysDelete every key in the current database.FLUSHALL ASYNCdestroysDelete every key in every database.SHUTDOWN NOSAVEdestroysStop the server without a final snapshot.CONFIG SET appendonly yesTurn on AOF durability if it's off.
Core five
| String | text, number, or binary blob up to 512MB |
| List | ordered, insert at either end |
| Hash | field→value map, like a flat object |
| Set | unordered, unique members |
| Sorted Set | unique members ranked by a float score |
Specialists
| Stream | append-only log with consumer groups |
| Bitmap | a string, addressed bit-by-bit |
| HyperLogLog | probabilistic distinct-count, ~12KB fixed |
| Geo | lat/lon points, backed by a sorted set |
| JSON (module) | native JSON via RedisJSON, if loaded |
| GET / SET | O(1) |
| LPUSH / RPUSH / LPOP / RPOP | O(1) |
| LRANGE key 0 -1 | O(N) |
| HSET / HGET | O(1) |
| SADD / SISMEMBER | O(1) |
| ZADD / ZSCORE | O(log N) |
| ZRANGE / ZRANGEBYSCORE | O(log N + M) |
| KEYS pattern | O(N) — avoid |
| SCAN (per call) | O(1) amortized |