Docs Command Reference

Command Reference

Complete reference for all 100+ Redis-compatible commands

S Strings

SET

Set a key to a string value with optional flags and expiry.
SET key value [NX|XX] [GET] [EX seconds | PX milliseconds]
NX — only set if key does not exist. XX — only set if key exists. GET — return the old value. EX/PX — set TTL in seconds/milliseconds.
> SET mykey hello
OK
> SET mykey world NX
(nil)
> SET session token123 EX 3600
OK
> SET mykey newval GET
"hello"

GET

Get the value of a key. Returns nil if the key does not exist.
GET key
> SET greeting "hello world"
OK
> GET greeting
"hello world"
> GET nonexistent
(nil)

SETNX

Set key only if it does not exist. Returns 1 if set, 0 if key already existed.
SETNX key value
> SETNX lock owner1
(integer) 1
> SETNX lock owner2
(integer) 0

SETEX / PSETEX

Set key with an expiry. SETEX uses seconds, PSETEX uses milliseconds.
SETEX key seconds value
PSETEX key milliseconds value
> SETEX cache:page 60 "<html>..."
OK
> TTL cache:page
(integer) 60

GETSET

Atomically set a new value and return the old value.
GETSET key value
> SET counter 10
OK
> GETSET counter 0
"10"

MSET / MSETNX / MGET

Multi-key operations. MSET sets multiple keys atomically. MSETNX only if none exist. MGET returns multiple values.
MSET key value [key value ...]
MSETNX key value [key value ...]
MGET key [key ...]
> MSET a 1 b 2 c 3
OK
> MGET a b c
1) "1"
2) "2"
3) "3"
> MSETNX x 10 y 20 a 99
(integer) 0
# Failed because 'a' already exists

APPEND / STRLEN

APPEND adds to the end of a string. STRLEN returns the length.
APPEND key value
STRLEN key
> SET msg "hello"
OK
> APPEND msg " world"
(integer) 11
> STRLEN msg
(integer) 11

INCR / DECR / INCRBY / DECRBY / INCRBYFLOAT

Atomic numeric operations. Auto-creates key with value 0 if it doesn't exist.
INCR key
DECR key
INCRBY key amount
DECRBY key amount
INCRBYFLOAT key amount
> INCR views
(integer) 1
> INCRBY views 100
(integer) 101
> DECRBY views 50
(integer) 51
> SET price 10.50
OK
> INCRBYFLOAT price 2.75
"13.25"

GETDEL / GETEX

GETDEL returns and deletes the value atomically. GETEX returns value and optionally sets expiry.
GETDEL key
GETEX key [EX seconds | PX milliseconds | PERSIST]
> SET temp "value"
OK
> GETDEL temp
"value"
> GET temp
(nil)
> SET session "data"
OK
> GETEX session EX 3600
"data"

GETRANGE / SETRANGE

GETRANGE returns a substring. SETRANGE overwrites bytes starting at offset.
GETRANGE key start end
SETRANGE key offset value
> SET greeting "hello world"
OK
> GETRANGE greeting 0 4
"hello"
> GETRANGE greeting -6 -1
"world"
> SETRANGE greeting 6 "rust"
(integer) 11
> GET greeting
"hello rust"

L Lists

Backed by a VecDeque — O(1) push/pop at both ends, O(1) random access.

LPUSH / RPUSH

Push elements to the head (LPUSH) or tail (RPUSH) of a list. Creates the list if it doesn't exist. Returns the new length.
LPUSH key value [value ...]
RPUSH key value [value ...]
> RPUSH queue job1 job2 job3
(integer) 3
> LPUSH queue urgent
(integer) 4
> LRANGE queue 0 -1
1) "urgent"
2) "job1"
3) "job2"
4) "job3"

LPOP / RPOP

Remove and return an element from the head (LPOP) or tail (RPOP). Returns nil if empty. Optional count removes multiple elements.
LPOP key [count]
RPOP key [count]
> RPUSH tasks a b c d e
(integer) 5
> LPOP tasks
"a"
> RPOP tasks 2
1) "d"
2) "e"

LLEN / LRANGE / LINDEX / LSET

Query and modify list elements. Negative indices count from the tail (-1 is last).
LLEN key
LRANGE key start stop
LINDEX key index
LSET key index value
> RPUSH colors red green blue
(integer) 3
> LLEN colors
(integer) 3
> LINDEX colors -1
"blue"
> LSET colors 1 yellow
OK
> LRANGE colors 0 -1
1) "red"
2) "yellow"
3) "blue"

LREM / LTRIM / LINSERT / LPOS

Advanced list manipulation.
LREM key count value
LTRIM key start stop
LINSERT key BEFORE|AFTER pivot value
LPOS key value
LREM count>0 — remove first N from head. count<0 — remove first N from tail. count=0 — remove all.
> RPUSH mylist a b c b d
(integer) 5
> LREM mylist 1 b
(integer) 1
> LPOS mylist d
(integer) 3
> LINSERT mylist BEFORE c X
(integer) 5
> LTRIM mylist 0 2
OK
> LRANGE mylist 0 -1
1) "a"
2) "X"
3) "c"

H Hashes

HSET / HGET / HDEL / HEXISTS

Basic hash field operations. HSET can set multiple fields at once.
HSET key field value [field value ...]
HGET key field
HDEL key field [field ...]
HEXISTS key field
> HSET user:1 name Alice age 30 city NYC
(integer) 3
> HGET user:1 name
"Alice"
> HEXISTS user:1 age
(integer) 1
> HDEL user:1 city
(integer) 1

HGETALL / HKEYS / HVALS / HLEN / HMSET / HMGET / HINCRBY / HINCRBYFLOAT

Bulk hash operations and introspection.
HGETALL key
HKEYS key
HVALS key
HLEN key
HMSET key field val [field val ...]
HMGET key field [field ...]
HINCRBY key field amount
HINCRBYFLOAT key field amount
> HGETALL user:1
1) "name"
2) "Alice"
3) "age"
4) "30"
> HKEYS user:1
1) "name"
2) "age"
> HINCRBY user:1 age 1
(integer) 31
> HINCRBYFLOAT user:1 score 5.5
"5.5"
> HMGET user:1 name age email
1) "Alice"
2) "31"
3) (nil)

HSETNX / HSCAN

HSETNX sets a field only if it doesn't exist. HSCAN iterates over hash fields.
HSETNX key field value
HSCAN key cursor [MATCH pattern] [COUNT count]
> HSET user:1 name Alice
(integer) 1
> HSETNX user:1 name Bob
(integer) 0
> HSCAN user:1 0
1) "0"
2) 1) "name"
3) "Alice"

S Sets

SADD / SREM / SMEMBERS / SISMEMBER / SCARD

Basic set operations.
SADD key member [member ...]
SREM key member [member ...]
SMEMBERS key
SISMEMBER key member
SCARD key
> SADD tags redis nosql fast
(integer) 3
> SISMEMBER tags redis
(integer) 1
> SCARD tags
(integer) 3
> SMEMBERS tags
1) "fast"
2) "nosql"
3) "redis"

SPOP / SRANDMEMBER / SUNION / SINTER / SDIFF / SMOVE

Random access and set algebra. SMOVE moves a member between sets.
SPOP key [count]
SRANDMEMBER key [count]
SUNION key [key ...]
SINTER key [key ...]
SDIFF key [key ...]
SMOVE source destination member
> SADD s1 a b c d
(integer) 4
> SADD s2 c d e f
(integer) 4
> SINTER s1 s2
1) "c"
2) "d"
> SDIFF s1 s2
1) "a"
2) "b"
> SMOVE s1 s2 a
(integer) 1
> SMEMBERS s2
1) "a"
2) "c"
3) "d"
4) "e"
5) "f"

Z Sorted Sets

ZADD / ZREM / ZSCORE / ZRANK / ZREVRANK

Add scored members and query individual scores/ranks.
ZADD key [NX|XX] [GT|LT] score member [score member ...]
ZREM key member [member ...]
ZSCORE key member
ZRANK key member
ZREVRANK key member
> ZADD leaderboard 100 alice 200 bob 150 charlie
(integer) 3
> ZSCORE leaderboard bob
"200"
> ZRANK leaderboard alice
(integer) 0
# alice has the lowest score, so rank 0
> ZREVRANK leaderboard alice
(integer) 2
# alice is last when sorted high-to-low

ZRANGE / ZREVRANGE / ZRANGEBYSCORE

Range queries by rank or score. Use WITHSCORES to include scores. Use -inf/+inf for open ranges.
ZRANGE key start stop [WITHSCORES]
ZREVRANGE key start stop [WITHSCORES]
ZRANGEBYSCORE key min max [LIMIT offset count]
> ZRANGE leaderboard 0 -1 WITHSCORES
1) "alice"
2) "100"
3) "charlie"
4) "150"
5) "bob"
6) "200"
> ZRANGEBYSCORE leaderboard 100 160
1) "alice"
2) "charlie"
> ZREVRANGE leaderboard 0 0 WITHSCORES
1) "bob"
2) "200"
# Top scorer

ZCARD / ZCOUNT / ZINCRBY / ZREMRANGEBYSCORE

Counting, incrementing, and bulk removal.
ZCARD key
ZCOUNT key min max
ZINCRBY key increment member
ZREMRANGEBYSCORE key min max
> ZCARD leaderboard
(integer) 3
> ZCOUNT leaderboard 100 200
(integer) 3
> ZINCRBY leaderboard 50 alice
"150"
> ZREMRANGEBYSCORE leaderboard -inf 100
(integer) 0
# No members with score <= 100 after ZINCRBY

ZPOPMIN / ZPOPMAX

Remove and return the lowest/highest scoring members.
ZPOPMIN key [count]
ZPOPMAX key [count]
> ZADD prices 10 apple 30 banana 20 cherry
(integer) 3
> ZPOPMIN prices 2
1) "apple"
2) "10"
3) "cherry"
4) "20"
> ZPOPMAX prices
1) "banana"
2) "30"

ZUNIONSTORE / ZINTERSTORE

Store the union/intersection of sorted sets with optional weights and aggregation.
ZUNIONSTORE dest numkeys key [key ...] [WEIGHTS weight ...] [AGGREGATE SUM|MIN|MAX]
ZINTERSTORE dest numkeys key [key ...] [WEIGHTS weight ...] [AGGREGATE SUM|MIN|MAX]
> ZADD z1 1 a 2 b
(integer) 2
> ZADD z2 1 b 2 c
(integer) 2
> ZUNIONSTORE result 2 z1 z2
(integer) 3
> ZRANGE result 0 -1 WITHSCORES
1) "a"
2) "1"
3) "b"
4) "3"
5) "c"
6) "2"

ZSCAN

Iterate over members in a sorted set.
ZSCAN key cursor [MATCH pattern] [COUNT count]
> ZSCAN leaderboard 0
1) "0"
2) 1) "alice"
3) "100"
4) "bob"
5) "200"

S Streams

XADD / XLEN

Append entries to a stream and query its length. Use * for auto-generated IDs. NOMKSTREAM prevents creating a new stream. MAXLEN/MINID trim older entries on write.
XADD key [NOMKSTREAM] [MAXLEN|MINID [=|~] N] *|id field value [field value ...]
XLEN key
> XADD events * user alice action login
"1709000000000-0"
> XADD events * user bob action purchase item hat
"1709000000001-0"
> XADD events MAXLEN 1000 * user charlie action logout
"1709000000002-0"
# Trims stream to 1000 entries after adding
> XLEN events
(integer) 3

XRANGE / XREVRANGE

Query entries by ID range. Use - for minimum and + for maximum. XREVRANGE returns entries in reverse order. COUNT limits results.
XRANGE key start end [COUNT n]
XREVRANGE key end start [COUNT n]
> XRANGE events - +
1) 1) "1709000000000-0"
   2) 1) "user" 2) "alice" 3) "action" 4) "login"
2) 1) "1709000000001-0"
   2) 1) "user" 2) "bob" 3) "action" 4) "purchase" 5) "item" 6) "hat"
3) 1) "1709000000002-0"
   2) 1) "user" 2) "charlie" 3) "action" 4) "logout"
> XRANGE events 1709000000001-0 + COUNT 1
1) 1) "1709000000001-0"
   2) 1) "user" 2) "bob" 3) "action" 4) "purchase" 5) "item" 6) "hat"
> XREVRANGE events + - COUNT 1
1) 1) "1709000000002-0"
   2) 1) "user" 2) "charlie" 3) "action" 4) "logout"
# Most recent entry

XREAD

Read new entries from one or more streams after the given IDs. Use 0-0 to read from the beginning. BLOCK is accepted but returns immediately in v1.
XREAD [COUNT n] [BLOCK ms] STREAMS key [key ...] id [id ...]
> XREAD COUNT 2 STREAMS events 0-0
1) 1) "events"
   2) 1) 1) "1709000000000-0"
       2) 1) "user" 2) "alice" 3) "action" 4) "login"
      2) 1) "1709000000001-0"
       2) 1) "user" 2) "bob" 3) "action" 4) "purchase" 5) "item" 6) "hat"
> XREAD STREAMS events 1709000000002-0
(nil)
# No entries after the last ID

XDEL / XTRIM

Remove specific entries or trim the stream. MAXLEN caps the total number of entries. MINID removes entries below a threshold ID. Use ~ for approximate trimming.
XDEL key id [id ...]
XTRIM key MAXLEN|MINID [=|~] N
> XDEL events 1709000000000-0
(integer) 1
> XLEN events
(integer) 2
> XTRIM events MAXLEN 1
(integer) 1
# Removed 1 entry, stream now has 1 entry
> XTRIM events MINID 1709000000003-0
(integer) 1
# Removed entries older than the given ID

XINFO

Introspect stream metadata: length, first/last entry, consumer group count, and last generated ID.
XINFO STREAM key
> XADD logs * level info msg "server started"
"1709000000000-0"
> XINFO STREAM logs
 1) "length"
 2) (integer) 1
 3) "first-entry"
 4) 1) "1709000000000-0"
    2) 1) "level" 2) "info" 3) "msg" 4) "server started"
 5) "last-entry"
 6) 1) "1709000000000-0"
    2) 1) "level" 2) "info" 3) "msg" 4) "server started"
 7) "groups"
 8) (integer) 0
 9) "last-generated-id"
10) "1709000000000-0"

XGROUP CREATE / DESTROY / DELCONSUMER

Manage consumer groups. CREATE attaches a group to a stream starting from a given ID (0 = all history, $ = new entries only). MKSTREAM creates the stream if it doesn't exist. DELCONSUMER removes a consumer and its pending entries.
XGROUP CREATE key group id|$ [MKSTREAM]
XGROUP DESTROY key group
XGROUP DELCONSUMER key group consumer
> XGROUP CREATE events workers 0
OK
# Group "workers" reads all existing entries
> XGROUP CREATE newstream analytics $ MKSTREAM
OK
# Creates the stream + group, reads only new entries
> XGROUP DELCONSUMER events workers consumer1
(integer) 0
# Returns the number of pending entries that were deleted
> XGROUP DESTROY events workers
(integer) 1

XREADGROUP

Read entries via a consumer group. Use > to get new undelivered entries. Use 0 to re-read your own pending entries. Each delivered entry is tracked until acknowledged with XACK.
XREADGROUP GROUP group consumer [COUNT n] [BLOCK ms] STREAMS key [key ...] id [id ...]
> XADD tasks * job build
"1709000000000-0"
> XADD tasks * job test
"1709000000001-0"
> XGROUP CREATE tasks ci 0
OK
> XREADGROUP GROUP ci runner1 COUNT 1 STREAMS tasks >
1) 1) "tasks"
   2) 1) 1) "1709000000000-0"
       2) 1) "job" 2) "build"
> XREADGROUP GROUP ci runner1 COUNT 10 STREAMS tasks >
1) 1) "tasks"
   2) 1) 1) "1709000000001-0"
       2) 1) "job" 2) "test"
# Each call delivers the next undelivered entry
> XREADGROUP GROUP ci runner1 STREAMS tasks 0
# Re-reads all pending entries for runner1

XACK

Acknowledge processed entries. Removes them from the consumer's pending list. Returns the number of entries successfully acknowledged.
XACK key group id [id ...]
> XACK tasks ci 1709000000000-0
(integer) 1
> XACK tasks ci 1709000000000-0 1709000000001-0
(integer) 1
# First ID was already acked, only second counts

XPENDING

Inspect pending entries. Summary form shows total count, min/max ID, and per-consumer counts. Detail form shows individual entries with idle time and delivery count.
XPENDING key group
XPENDING key group start end count [consumer]
> XPENDING tasks ci
1) (integer) 2
2) "1709000000000-0"
3) "1709000000001-0"
4) 1) 1) "runner1"
     2) "2"
# Summary: 2 pending, min/max IDs, runner1 has 2
> XPENDING tasks ci - + 10
1) 1) "1709000000000-0"
   2) "runner1"
   3) (integer) 5000
   4) (integer) 1
2) 1) "1709000000001-0"
   2) "runner1"
   3) (integer) 3000
   4) (integer) 1
# Detail: ID, consumer, idle ms, delivery count
> XPENDING tasks ci - + 10 runner1
# Same but filtered to a specific consumer

K Keys

DEL / UNLINK / EXISTS / TYPE / RENAME / RENAMENX

Key management. UNLINK is async alternative to DEL. These work across all data types.
DEL key [key ...]
UNLINK key [key ...]
EXISTS key [key ...]
TYPE key
RENAME key newkey
RENAMENX key newkey
> SET foo bar
OK
> TYPE foo
string
> EXISTS foo
(integer) 1
> RENAME foo baz
OK
> UNLINK baz
(integer) 1

EXPIRE / PEXPIRE / EXPIREAT / PEXPIREAT / TTL / PTTL / PERSIST / KEYS

TTL management and key search. EXPIRE/PEXPIRE set relative TTL. EXPIREAT/PEXPIREAT set absolute timestamp.
EXPIRE key seconds
PEXPIRE key milliseconds
EXPIREAT key timestamp
PEXPIREAT key milliseconds
TTL key
PTTL key
PERSIST key
KEYS pattern
> SET temp hello
OK
> EXPIRE temp 30
(integer) 1
> TTL temp
(integer) 30
> PERSIST temp
(integer) 1
> KEYS user:*
1) "user:1"

SCAN / RANDOMKEY / OBJECT

Key iteration and introspection. SCAN iterates keys without blocking. OBJECT reports internal encoding.
SCAN cursor [MATCH pattern] [COUNT count]
RANDOMKEY
OBJECT ENCODING key
> SCAN 0 MATCH user:* COUNT 100
1) "0"
2) 1) "user:1"
3) "user:2"
> RANDOMKEY
"user:1"
> OBJECT ENCODING mystring
"embstr"

T Transactions

MULTI / EXEC / DISCARD

Queue commands with MULTI, then execute atomically with EXEC. All commands between MULTI and EXEC run under a single write lock. DISCARD aborts the transaction.
MULTI
EXEC
DISCARD
> MULTI
OK
> SET account:1:balance 500
QUEUED
> SET account:2:balance 1500
QUEUED
> EXEC
1) OK
2) OK
> MULTI
OK
> SET x 1
QUEUED
> DISCARD
OK
# Transaction aborted, x was not set

P Pub/Sub

SUBSCRIBE / UNSUBSCRIBE / PUBLISH / PSUBSCRIBE / PUNSUBSCRIBE / PUBSUB

Publish-subscribe messaging. PSUBSCRIBE supports glob patterns. PUBSUB provides introspection.
SUBSCRIBE channel [channel ...]
UNSUBSCRIBE [channel ...]
PUBLISH channel message
PSUBSCRIBE pattern [pattern ...]
PUNSUBSCRIBE [pattern ...]
PUBSUB CHANNELS [pattern]
PUBSUB NUMSUB [channel ...]
Terminal 1 (subscriber)
> SUBSCRIBE news
1) "subscribe"
2) "news"
3) (integer) 1
# Waiting for messages...
1) "message"
2) "news"
3) "breaking: SoliKV released"
Terminal 2 (publisher)
> PUBLISH news "breaking: SoliKV released"
(integer) 1
# 1 subscriber received it
> PUBSUB CHANNELS
1) "news"

Keyspace Notifications

Enable event-driven notifications when keys are modified, deleted, or expire. Clients subscribe via PSUBSCRIBE to channels like __keyevent@0__:expired or __keyspace@0__:mykey. Disabled by default — enable with CONFIG SET notify-keyspace-events.
K — keyspace events (__keyspace@0__:<key>). E — keyevent events (__keyevent@0__:<event>). g — generic commands (DEL, EXPIRE, RENAME...). $ — string commands. l — list commands. s — set commands. h — hash commands. z — sorted set commands. t — stream commands. x — expired events. e — evicted events. A — alias for g$lshztxe (all events).
CONFIG SET notify-keyspace-events KEA
Terminal 1 (subscriber)
> PSUBSCRIBE __keyevent@0__:*
# Waiting for events...
1) "pmessage"
2) "__keyevent@0__:*"
3) "__keyevent@0__:set"
4) "mykey"
1) "pmessage"
2) "__keyevent@0__:*"
3) "__keyevent@0__:expired"
4) "mykey"
Terminal 2 (publisher)
> CONFIG SET notify-keyspace-events KEA
OK
> SET mykey hello PX 1000
OK
# After 1 second, expired event fires

L Scripting

EVAL

Execute a Lua script server-side. Scripts receive KEYS and ARGV tables, and can call Redis commands via redis.call() and redis.pcall().
EVAL script numkeys [key ...] [arg ...]
> EVAL "return 42" 0
(integer) 42
> EVAL "return redis.call('SET',KEYS[1],ARGV[1])" 1 mykey myval
OK
> EVAL "return redis.call('GET',KEYS[1])" 1 mykey
"myval"
> EVAL "return {1, 2, 3}" 0
1) (integer) 1
2) (integer) 2
3) (integer) 3

EVALSHA

Execute a cached script by its SHA1 digest. Use SCRIPT LOAD to cache scripts first. Returns NOSCRIPT error if the script is not cached.
EVALSHA sha1 numkeys [key ...] [arg ...]
> EVALSHA e0e1f9fabfc9d4800c877a703b823ac0578ff831 0
"hello"

SCRIPT LOAD

Cache a Lua script and return its SHA1 digest for later use with EVALSHA.
SCRIPT LOAD script
> SCRIPT LOAD "return 'hello'"
"e0e1f9fabfc9d4800c877a703b823ac0578ff831"

SCRIPT EXISTS

Check if one or more scripts are cached. Returns an array of 1 (cached) or 0 (not cached) for each SHA1.
SCRIPT EXISTS sha1 [sha1 ...]
> SCRIPT EXISTS e0e1f9fabfc9d4800c877a703b823ac0578ff831 0000000000000000000000000000000000000000
1) (integer) 1
2) (integer) 0

SCRIPT FLUSH

Clear the script cache. All previously loaded scripts will need to be re-loaded.
SCRIPT FLUSH
> SCRIPT FLUSH
OK

B Bitmap

SETBIT

Set or clear the bit at offset in the string value stored at key. Returns the original bit value. The string is auto-grown with zero bytes to ensure the offset can be addressed.
SETBIT key offset value
> SETBIT mykey 7 1
(integer) 0
> SETBIT mykey 7 0
(integer) 1

GETBIT

Returns the bit value at offset in the string value stored at key. Returns 0 if the key does not exist or the offset is beyond the string length.
GETBIT key offset
> SETBIT mykey 7 1
(integer) 0
> GETBIT mykey 7
(integer) 1
> GETBIT mykey 100
(integer) 0

BITCOUNT

Count the number of set bits (population counting) in a string. By default examines all bytes; optional start/end specify a byte range (negative indices count from the end).
BITCOUNT key [start end]
> SET mykey "\xff\xf0"
OK
> BITCOUNT mykey
(integer) 12
> BITCOUNT mykey 0 0
(integer) 8

BITOP

Perform a bitwise operation between multiple keys and store the result in the destination key. Supported operations: AND, OR, XOR, NOT. NOT takes exactly one source key. Shorter strings are zero-padded.
BITOP operation destkey key [key ...]
> SET k1 "\xff"
OK
> SET k2 "\x0f"
OK
> BITOP AND dest k1 k2
(integer) 1
> BITOP NOT negated k1
(integer) 1

H HyperLogLog

PFADD

Add elements to a HyperLogLog. Returns 1 if any internal register was altered, 0 otherwise.
PFADD key element [element ...]
> PFADD visitors alice bob charlie alice
(integer) 1
> PFADD visitors alice
(integer) 0

PFCOUNT

Return the approximate cardinality of the set(s). Multiple keys are merged internally before counting.
PFCOUNT key [key ...]
> PFCOUNT visitors
(integer) 3

PFMERGE

Merge multiple HyperLogLogs into a destination key. Creates or overwrites the destination.
PFMERGE destkey sourcekey [sourcekey ...]
> PFMERGE all visitors1 visitors2
OK
> PFCOUNT all
(integer) 5

B Bloom Filter

BF.RESERVE

Create an empty Bloom filter with a given desired error rate and initial capacity. The filter auto-creates with defaults (0.01 error, 100 capacity) on first BF.ADD if not reserved.
BF.RESERVE key error_rate capacity
> BF.RESERVE myfilter 0.001 10000
OK

BF.ADD

Add an item to the Bloom filter. Returns 1 if the item was newly added, 0 if it may have existed.
BF.ADD key item
> BF.ADD myfilter hello
(integer) 1

BF.MADD

Add multiple items to the Bloom filter. Returns an array of 1/0 for each item.
BF.MADD key item [item ...]
> BF.MADD myfilter foo bar baz
1) (integer) 1
2) (integer) 1
3) (integer) 1

BF.EXISTS

Check if an item may exist in the Bloom filter. Returns 1 if it may exist (possible false positive), 0 if it definitely does not.
BF.EXISTS key item
> BF.EXISTS myfilter hello
(integer) 1
> BF.EXISTS myfilter unknown
(integer) 0

BF.MEXISTS

Check if multiple items may exist in the Bloom filter. Returns an array of 1/0 for each item.
BF.MEXISTS key item [item ...]
> BF.MEXISTS myfilter hello unknown
1) (integer) 1
2) (integer) 0

BF.INFO

Return information about a Bloom filter: capacity, size, number of filters, items inserted, and expansion rate.
BF.INFO key
> BF.INFO myfilter
1) "Capacity"
2) (integer) 10000
3) "Size"
4) (integer) 14378
5) "Number of filters"
6) (integer) 1
7) "Number of items inserted"
8) (integer) 42
9) "Expansion rate"
10) (integer) 0

G Geospatial

GEOADD

Add one or more geospatial items (longitude, latitude, name) to a sorted set. Items are stored as 52-bit geohash scores.
GEOADD key [NX|XX] [CH] longitude latitude member [longitude latitude member ...]
> GEOADD mygeo 13.361389 38.115556 "Palermo" 15.087269 37.502669 "Catania"
(integer) 2

GEOPOS

Return the longitude and latitude of one or more members. Returns nil for missing members.
GEOPOS key member [member ...]
> GEOPOS mygeo Palermo
1) 1) "13.36138933897018433"
2) "38.11555639549629859"

GEOHASH

Return the standard 11-character geohash string for one or more members.
GEOHASH key member [member ...]
> GEOHASH mygeo Palermo
1) "sqc8b49rny0"

GEODIST

Return the distance between two members. Supports m (meters), km, ft, mi units. Returns nil if either member is missing.
GEODIST key member1 member2 [M|KM|FT|MI]
> GEODIST mygeo Palermo Catania km
"166.2742"

GEOSEARCH

Search for members within a radius or bounding box from a center point (coordinates or existing member). Supports sorting, counting, and returning coordinates/distances.
GEOSEARCH key FROMMEMBER member | FROMLONLAT lon lat BYRADIUS radius M|KM|FT|MI | BYBOX width height M|KM|FT|MI [ASC|DESC] [COUNT count [ANY]] [WITHCOORD] [WITHDIST] [WITHHASH]
> GEOSEARCH mygeo FROMLONLAT 15 37 BYRADIUS 200 km ASC
1) "Catania"
2) "Palermo"

GEOSEARCHSTORE

Like GEOSEARCH, but stores the results in a destination sorted set. With STOREDIST, stores the distance as the score instead of the geohash.
GEOSEARCHSTORE dest src FROMMEMBER member | FROMLONLAT lon lat BYRADIUS radius M|KM|FT|MI | BYBOX width height M|KM|FT|MI [ASC|DESC] [COUNT count [ANY]] [STOREDIST]
> GEOSEARCHSTORE nearby mygeo FROMLONLAT 15 37 BYRADIUS 200 km ASC
(integer) 2

* Server

PING / ECHO / QUIT / SELECT / DBSIZE / FLUSHDB / FLUSHALL / INFO / COMMAND / CONFIG / TIME / CLIENT / RESET / SAVE / BGSAVE / ROLE / REPLICAOF

Server management, diagnostics, persistence, and replication.
PING [message]
ECHO message
QUIT
RESET
SELECT db (0-15)
DBSIZE
FLUSHDB
FLUSHALL
INFO [section]
COMMAND [DOCS|COUNT]
CONFIG GET pattern
TIME
CLIENT SETNAME name
CLIENT GETNAME
CLIENT ID
SAVE
BGSAVE
ROLE
REPLICAOF host port
REPLICAOF NO ONE
> PING
PONG
> ROLE
1) "master"
2) "0"
3)
> REPLICAOF 127.0.0.1 6379
OK
> ROLE
1) "slave"
2) "127.0.0.1:6379"
3) "connect"

CLUSTER INFO / NODES / SLOTS / MEET / ADDSLOTS / DELSLOTS / KEYSLOT

Redis Cluster-compatible commands for sharding and node management.
CLUSTER INFO
CLUSTER NODES
CLUSTER SLOTS
CLUSTER MEET ip port
CLUSTER ADDSLOTS slot [slot...]
CLUSTER DELSLOTS slot [slot...]
CLUSTER KEYSLOT key
> CLUSTER INFO
cluster_state:ok
cluster_slots_assigned:16384
...
> CLUSTER NODES
node_id 127.0.0.1@7000 myself,master - 0-16383
> CLUSTER KEYSLOT mykey
(integer) 12591
> CLUSTER MEET 127.0.0.1 7001
OK
> CLUSTER ADDSLOTS 0 5000
OK

Type Safety

All typed commands check the key type first. Using a list command on a string key (or vice versa) returns:

-WRONGTYPE Operation against a key holding the wrong kind of value