Skip to content

Redis Commands Reference

ParticleDB implements the Redis RESP protocol on port 6379, allowing any Redis client library or redis-cli to interact with ParticleDB as a key-value and data-structure store. All data is persisted through the same ACID storage engine used by SQL queries — writes via Redis are immediately visible through PostgreSQL, gRPC, and every other protocol.

Terminal window
# Connect with redis-cli
redis-cli -p 6379
# Connect with authentication
redis-cli -p 6379 -a your_password
# Connect to a specific database
redis-cli -p 6379 -n 0

Any standard Redis client library (ioredis, redis-py, Jedis, etc.) works with ParticleDB’s RESP server.


String commands operate on simple key-value pairs. Values can be strings, integers, or arbitrary byte sequences.

Set the value of a key, with optional expiration and conditional flags.

Syntax:

SET key value [EX seconds] [PX milliseconds] [NX | XX]
OptionDescription
EXSet expiration in seconds
PXSet expiration in milliseconds
NXOnly set if the key does not already exist
XXOnly set if the key already exists

Return value: OK on success, nil if the condition (NX/XX) was not met.

Terminal window
127.0.0.1:6379> SET user:1:name "Alice"
OK
127.0.0.1:6379> SET session:abc token123 EX 3600
OK
127.0.0.1:6379> SET lock:order NX EX 30
OK

Get the value of a key.

Syntax:

GET key

Return value: The value of the key, or nil if the key does not exist.

Terminal window
127.0.0.1:6379> GET user:1:name
"Alice"
127.0.0.1:6379> GET nonexistent
(nil)

Set the value of a key only if it does not already exist. Equivalent to SET key value NX.

Syntax:

SETNX key value

Return value: 1 if the key was set, 0 if it already existed.

Terminal window
127.0.0.1:6379> SETNX mykey "Hello"
(integer) 1
127.0.0.1:6379> SETNX mykey "World"
(integer) 0
127.0.0.1:6379> GET mykey
"Hello"

Set the value and expiration (in seconds) of a key. Equivalent to SET key value EX seconds.

Syntax:

SETEX key seconds value

Return value: OK.

Terminal window
127.0.0.1:6379> SETEX cache:page:home 300 "<html>...</html>"
OK
127.0.0.1:6379> TTL cache:page:home
(integer) 300

Atomically set a key to a new value and return its old value.

Syntax:

GETSET key value

Return value: The old value of the key, or nil if it did not exist.

Terminal window
127.0.0.1:6379> SET counter "10"
OK
127.0.0.1:6379> GETSET counter "0"
"10"
127.0.0.1:6379> GET counter
"0"

Get the values of multiple keys in a single round trip.

Syntax:

MGET key [key ...]

Return value: An array of values (or nil for keys that do not exist).

Terminal window
127.0.0.1:6379> SET key1 "a"
OK
127.0.0.1:6379> SET key2 "b"
OK
127.0.0.1:6379> MGET key1 key2 key3
1) "a"
2) "b"
3) (nil)

Set multiple key-value pairs in a single atomic operation.

Syntax:

MSET key value [key value ...]

Return value: OK (always succeeds).

Terminal window
127.0.0.1:6379> MSET user:1:name "Alice" user:1:email "alice@example.com"
OK
127.0.0.1:6379> MGET user:1:name user:1:email
1) "Alice"
2) "alice@example.com"

Increment the integer value of a key by one. If the key does not exist, it is set to 0 before the operation.

Syntax:

INCR key

Return value: The value after the increment.

Terminal window
127.0.0.1:6379> SET visits 100
OK
127.0.0.1:6379> INCR visits
(integer) 101
127.0.0.1:6379> INCR visits
(integer) 102

Decrement the integer value of a key by one.

Syntax:

DECR key

Return value: The value after the decrement.

Terminal window
127.0.0.1:6379> SET stock 50
OK
127.0.0.1:6379> DECR stock
(integer) 49

Increment the integer value of a key by a specified amount.

Syntax:

INCRBY key increment

Return value: The value after the increment.

Terminal window
127.0.0.1:6379> SET counter 10
OK
127.0.0.1:6379> INCRBY counter 5
(integer) 15

Decrement the integer value of a key by a specified amount.

Syntax:

DECRBY key decrement

Return value: The value after the decrement.

Terminal window
127.0.0.1:6379> SET counter 100
OK
127.0.0.1:6379> DECRBY counter 25
(integer) 75

Append a value to an existing string. If the key does not exist, it is created with the given value.

Syntax:

APPEND key value

Return value: The length of the string after the append.

Terminal window
127.0.0.1:6379> SET greeting "Hello"
OK
127.0.0.1:6379> APPEND greeting " World"
(integer) 11
127.0.0.1:6379> GET greeting
"Hello World"

Get the length of the string stored at a key.

Syntax:

STRLEN key

Return value: The length of the string, or 0 if the key does not exist.

Terminal window
127.0.0.1:6379> SET name "ParticleDB"
OK
127.0.0.1:6379> STRLEN name
(integer) 10

Lists are ordered sequences of strings. Elements can be pushed and popped from both ends, making them suitable for queues, stacks, and recent-activity feeds.

Insert one or more values at the head (left) of a list.

Syntax:

LPUSH key value [value ...]

Return value: The length of the list after the push.

Terminal window
127.0.0.1:6379> LPUSH tasks "send email" "write report"
(integer) 2
127.0.0.1:6379> LRANGE tasks 0 -1
1) "write report"
2) "send email"

Insert one or more values at the tail (right) of a list.

Syntax:

RPUSH key value [value ...]

Return value: The length of the list after the push.

Terminal window
127.0.0.1:6379> RPUSH queue "job1" "job2" "job3"
(integer) 3

Remove and return the first element of a list.

Syntax:

LPOP key

Return value: The removed element, or nil if the list is empty or does not exist.

Terminal window
127.0.0.1:6379> RPUSH queue "a" "b" "c"
(integer) 3
127.0.0.1:6379> LPOP queue
"a"

Remove and return the last element of a list.

Syntax:

RPOP key

Return value: The removed element, or nil if the list is empty or does not exist.

Terminal window
127.0.0.1:6379> RPUSH stack "x" "y" "z"
(integer) 3
127.0.0.1:6379> RPOP stack
"z"

Get the number of elements in a list.

Syntax:

LLEN key

Return value: The length of the list, or 0 if the key does not exist.

Terminal window
127.0.0.1:6379> RPUSH items "a" "b" "c"
(integer) 3
127.0.0.1:6379> LLEN items
(integer) 3

Get a range of elements from a list. Indices are zero-based; negative indices count from the end (-1 is the last element).

Syntax:

LRANGE key start stop

Return value: An array of elements in the specified range.

Terminal window
127.0.0.1:6379> RPUSH colors "red" "green" "blue" "yellow"
(integer) 4
127.0.0.1:6379> LRANGE colors 0 -1
1) "red"
2) "green"
3) "blue"
4) "yellow"
127.0.0.1:6379> LRANGE colors 1 2
1) "green"
2) "blue"

Get an element by its index in a list.

Syntax:

LINDEX key index

Return value: The element at the specified index, or nil if out of range.

Terminal window
127.0.0.1:6379> RPUSH letters "a" "b" "c"
(integer) 3
127.0.0.1:6379> LINDEX letters 0
"a"
127.0.0.1:6379> LINDEX letters -1
"c"

Set the value of an element at a specific index in a list.

Syntax:

LSET key index value

Return value: OK on success. Returns an error if the index is out of range.

Terminal window
127.0.0.1:6379> RPUSH fruits "apple" "banana" "cherry"
(integer) 3
127.0.0.1:6379> LSET fruits 1 "blueberry"
OK
127.0.0.1:6379> LRANGE fruits 0 -1
1) "apple"
2) "blueberry"
3) "cherry"

Sets are unordered collections of unique strings. They support membership tests, intersections, unions, and differences.

Add one or more members to a set.

Syntax:

SADD key member [member ...]

Return value: The number of members that were added (excluding already-present members).

Terminal window
127.0.0.1:6379> SADD tags "rust" "database" "olap"
(integer) 3
127.0.0.1:6379> SADD tags "rust"
(integer) 0

Get all members of a set.

Syntax:

SMEMBERS key

Return value: An array of all members.

Terminal window
127.0.0.1:6379> SADD colors "red" "blue" "green"
(integer) 3
127.0.0.1:6379> SMEMBERS colors
1) "blue"
2) "green"
3) "red"

Test if a value is a member of a set.

Syntax:

SISMEMBER key member

Return value: 1 if the member exists, 0 otherwise.

Terminal window
127.0.0.1:6379> SADD fruits "apple" "banana"
(integer) 2
127.0.0.1:6379> SISMEMBER fruits "apple"
(integer) 1
127.0.0.1:6379> SISMEMBER fruits "cherry"
(integer) 0

Remove one or more members from a set.

Syntax:

SREM key member [member ...]

Return value: The number of members that were removed.

Terminal window
127.0.0.1:6379> SADD myset "a" "b" "c"
(integer) 3
127.0.0.1:6379> SREM myset "b"
(integer) 1
127.0.0.1:6379> SMEMBERS myset
1) "a"
2) "c"

Get the number of members in a set.

Syntax:

SCARD key

Return value: The cardinality (number of elements) of the set.

Terminal window
127.0.0.1:6379> SADD myset "a" "b" "c"
(integer) 3
127.0.0.1:6379> SCARD myset
(integer) 3

Return the union of multiple sets.

Syntax:

SUNION key [key ...]

Return value: An array of members in the resulting union.

Terminal window
127.0.0.1:6379> SADD set1 "a" "b" "c"
(integer) 3
127.0.0.1:6379> SADD set2 "b" "c" "d"
(integer) 3
127.0.0.1:6379> SUNION set1 set2
1) "a"
2) "b"
3) "c"
4) "d"

Return the intersection of multiple sets.

Syntax:

SINTER key [key ...]

Return value: An array of members present in all given sets.

Terminal window
127.0.0.1:6379> SADD set1 "a" "b" "c"
(integer) 3
127.0.0.1:6379> SADD set2 "b" "c" "d"
(integer) 3
127.0.0.1:6379> SINTER set1 set2
1) "b"
2) "c"

Return the difference between the first set and all subsequent sets.

Syntax:

SDIFF key [key ...]

Return value: An array of members in the first set that are not in any other set.

Terminal window
127.0.0.1:6379> SADD set1 "a" "b" "c"
(integer) 3
127.0.0.1:6379> SADD set2 "b" "c" "d"
(integer) 3
127.0.0.1:6379> SDIFF set1 set2
1) "a"

Sorted sets associate a floating-point score with each member. Members are unique and ordered by score, enabling range queries and leaderboard-style access patterns.

Add one or more members with scores to a sorted set.

Syntax:

ZADD key score member [score member ...]

Return value: The number of members added (not including updated members).

Terminal window
127.0.0.1:6379> ZADD leaderboard 100 "alice" 85 "bob" 92 "charlie"
(integer) 3

Get the score of a member in a sorted set.

Syntax:

ZSCORE key member

Return value: The score as a string, or nil if the member does not exist.

Terminal window
127.0.0.1:6379> ZSCORE leaderboard "alice"
"100"

Get the rank (zero-based index) of a member, ordered from lowest to highest score.

Syntax:

ZRANK key member

Return value: The rank as an integer, or nil if the member does not exist.

Terminal window
127.0.0.1:6379> ZADD leaderboard 100 "alice" 85 "bob" 92 "charlie"
(integer) 3
127.0.0.1:6379> ZRANK leaderboard "bob"
(integer) 0
127.0.0.1:6379> ZRANK leaderboard "alice"
(integer) 2

Get a range of members by index (low to high score). Use WITHSCORES to include scores in the output.

Syntax:

ZRANGE key start stop [WITHSCORES]

Return value: An array of members (and optionally their scores).

Terminal window
127.0.0.1:6379> ZADD leaderboard 100 "alice" 85 "bob" 92 "charlie"
(integer) 3
127.0.0.1:6379> ZRANGE leaderboard 0 -1
1) "bob"
2) "charlie"
3) "alice"
127.0.0.1:6379> ZRANGE leaderboard 0 -1 WITHSCORES
1) "bob"
2) "85"
3) "charlie"
4) "92"
5) "alice"
6) "100"

Get members with scores within a given range. Use -inf and +inf for unbounded ranges. Prefix a value with ( for an exclusive bound.

Syntax:

ZRANGEBYSCORE key min max [WITHSCORES] [LIMIT offset count]

Return value: An array of members in the score range.

Terminal window
127.0.0.1:6379> ZADD temps 32.5 "NYC" 28.1 "LA" 35.0 "Phoenix" 22.3 "Seattle"
(integer) 4
127.0.0.1:6379> ZRANGEBYSCORE temps 25 33
1) "LA"
2) "NYC"
127.0.0.1:6379> ZRANGEBYSCORE temps -inf +inf WITHSCORES
1) "Seattle"
2) "22.3"
3) "LA"
4) "28.1"
5) "NYC"
6) "32.5"
7) "Phoenix"
8) "35"

Remove one or more members from a sorted set.

Syntax:

ZREM key member [member ...]

Return value: The number of members removed.

Terminal window
127.0.0.1:6379> ZADD scores 10 "a" 20 "b" 30 "c"
(integer) 3
127.0.0.1:6379> ZREM scores "b"
(integer) 1

Get the number of members in a sorted set.

Syntax:

ZCARD key

Return value: The cardinality of the sorted set.

Terminal window
127.0.0.1:6379> ZADD scores 10 "a" 20 "b" 30 "c"
(integer) 3
127.0.0.1:6379> ZCARD scores
(integer) 3

Hashes map field names to values within a single key. They are ideal for representing objects (e.g., user profiles, configuration entries).

Set one or more fields in a hash.

Syntax:

HSET key field value [field value ...]

Return value: The number of fields that were added (not updated).

Terminal window
127.0.0.1:6379> HSET user:1 name "Alice" email "alice@example.com" age "30"
(integer) 3

Get the value of a single field in a hash.

Syntax:

HGET key field

Return value: The value of the field, or nil if the field or key does not exist.

Terminal window
127.0.0.1:6379> HGET user:1 name
"Alice"
127.0.0.1:6379> HGET user:1 nonexistent
(nil)

Get all fields and values in a hash.

Syntax:

HGETALL key

Return value: An array of alternating field names and values.

Terminal window
127.0.0.1:6379> HSET user:1 name "Alice" email "alice@example.com"
(integer) 2
127.0.0.1:6379> HGETALL user:1
1) "name"
2) "Alice"
3) "email"
4) "alice@example.com"

Delete one or more fields from a hash.

Syntax:

HDEL key field [field ...]

Return value: The number of fields that were removed.

Terminal window
127.0.0.1:6379> HSET user:1 name "Alice" tmp "delete_me"
(integer) 2
127.0.0.1:6379> HDEL user:1 tmp
(integer) 1

Check if a field exists in a hash.

Syntax:

HEXISTS key field

Return value: 1 if the field exists, 0 otherwise.

Terminal window
127.0.0.1:6379> HSET user:1 name "Alice"
(integer) 1
127.0.0.1:6379> HEXISTS user:1 name
(integer) 1
127.0.0.1:6379> HEXISTS user:1 phone
(integer) 0

Get all field names in a hash.

Syntax:

HKEYS key

Return value: An array of field names.

Terminal window
127.0.0.1:6379> HSET config host "localhost" port "6379"
(integer) 2
127.0.0.1:6379> HKEYS config
1) "host"
2) "port"

Get all values in a hash.

Syntax:

HVALS key

Return value: An array of values.

Terminal window
127.0.0.1:6379> HSET config host "localhost" port "6379"
(integer) 2
127.0.0.1:6379> HVALS config
1) "localhost"
2) "6379"

Get the number of fields in a hash.

Syntax:

HLEN key

Return value: The number of fields.

Terminal window
127.0.0.1:6379> HSET user:1 name "Alice" email "alice@example.com" age "30"
(integer) 3
127.0.0.1:6379> HLEN user:1
(integer) 3

Increment the integer value of a hash field by a given amount.

Syntax:

HINCRBY key field increment

Return value: The value after the increment.

Terminal window
127.0.0.1:6379> HSET user:1 login_count 10
(integer) 1
127.0.0.1:6379> HINCRBY user:1 login_count 1
(integer) 11

Set multiple fields in a hash. Functionally identical to HSET with multiple field-value pairs (provided for compatibility).

Syntax:

HMSET key field value [field value ...]

Return value: OK.

Terminal window
127.0.0.1:6379> HMSET user:2 name "Bob" email "bob@example.com"
OK

Get the values of multiple fields in a hash.

Syntax:

HMGET key field [field ...]

Return value: An array of values (or nil for fields that do not exist).

Terminal window
127.0.0.1:6379> HSET user:1 name "Alice" email "alice@example.com" age "30"
(integer) 3
127.0.0.1:6379> HMGET user:1 name age phone
1) "Alice"
2) "30"
3) (nil)

Set the value of a hash field only if the field does not already exist.

Syntax:

HSETNX key field value

Return value: 1 if the field was set, 0 if it already existed.

Terminal window
127.0.0.1:6379> HSETNX user:1 name "Alice"
(integer) 1
127.0.0.1:6379> HSETNX user:1 name "Bob"
(integer) 0
127.0.0.1:6379> HGET user:1 name
"Alice"

Streams are append-only log data structures. Each entry has an auto-generated ID and a set of field-value pairs. Streams support consumer groups, range queries, and blocking reads.

Append an entry to a stream. Use * to auto-generate the entry ID.

Syntax:

XADD key id field value [field value ...]

Return value: The ID of the added entry.

Terminal window
127.0.0.1:6379> XADD events * action "click" page "/home"
"1679012345678-0"
127.0.0.1:6379> XADD events * action "scroll" page "/about"
"1679012345679-0"

Get the number of entries in a stream.

Syntax:

XLEN key

Return value: The number of entries.

Terminal window
127.0.0.1:6379> XLEN events
(integer) 2

Get entries in a stream within an ID range. Use - for the minimum ID and + for the maximum.

Syntax:

XRANGE key start end [COUNT count]

Return value: An array of entries, each containing its ID and field-value pairs.

Terminal window
127.0.0.1:6379> XRANGE events - +
1) 1) "1679012345678-0"
2) 1) "action"
2) "click"
3) "page"
4) "/home"
2) 1) "1679012345679-0"
2) 1) "action"
2) "scroll"
3) "page"
4) "/about"
127.0.0.1:6379> XRANGE events - + COUNT 1
1) 1) "1679012345678-0"
2) 1) "action"
2) "click"
3) "page"
4) "/home"

Get entries in reverse order (highest to lowest ID).

Syntax:

XREVRANGE key end start [COUNT count]

Return value: An array of entries in reverse order.

Terminal window
127.0.0.1:6379> XREVRANGE events + - COUNT 1
1) 1) "1679012345679-0"
2) 1) "action"
2) "scroll"
3) "page"
4) "/about"

Read entries from one or more streams, optionally blocking until new data arrives.

Syntax:

XREAD [COUNT count] [BLOCK milliseconds] STREAMS key [key ...] id [id ...]

Use $ as the ID to read only new entries that arrive after the command is issued (blocking mode).

Return value: An array of stream results, each containing the stream key and its entries. Returns nil if the timeout expires with no new data.

Terminal window
# Read up to 10 entries from "events" starting after ID 0
127.0.0.1:6379> XREAD COUNT 10 STREAMS events 0
1) 1) "events"
2) 1) 1) "1679012345678-0"
2) 1) "action"
2) "click"
3) "page"
4) "/home"
# Block for up to 5 seconds waiting for new entries
127.0.0.1:6379> XREAD COUNT 1 BLOCK 5000 STREAMS events $

Trim a stream to a maximum length, removing the oldest entries.

Syntax:

XTRIM key MAXLEN [~] count

Use ~ for approximate trimming (more efficient, may keep slightly more entries).

Return value: The number of entries removed.

Terminal window
127.0.0.1:6379> XTRIM events MAXLEN 1000
(integer) 0
127.0.0.1:6379> XTRIM events MAXLEN ~ 1000
(integer) 0

Get information about a stream.

Syntax:

XINFO STREAM key

Return value: A detailed map of stream metadata including length, first/last entry, and radix tree statistics.

Terminal window
127.0.0.1:6379> XINFO STREAM events
1) "length"
2) (integer) 2
3) "radix-tree-keys"
4) (integer) 1
5) "radix-tree-nodes"
6) (integer) 2
7) "last-generated-id"
8) "1679012345679-0"
9) "first-entry"
10) 1) "1679012345678-0"
2) 1) "action"
2) "click"
3) "page"
4) "/home"
11) "last-entry"
12) 1) "1679012345679-0"
2) 1) "action"
2) "scroll"
3) "page"
4) "/about"

Key commands operate on keys regardless of the underlying data type.

Delete one or more keys.

Syntax:

DEL key [key ...]

Return value: The number of keys that were deleted.

Terminal window
127.0.0.1:6379> SET a 1
OK
127.0.0.1:6379> SET b 2
OK
127.0.0.1:6379> DEL a b nonexistent
(integer) 2

Check if one or more keys exist.

Syntax:

EXISTS key [key ...]

Return value: The number of specified keys that exist.

Terminal window
127.0.0.1:6379> SET mykey "hello"
OK
127.0.0.1:6379> EXISTS mykey
(integer) 1
127.0.0.1:6379> EXISTS mykey otherkey
(integer) 1

Get the data type of a key.

Syntax:

TYPE key

Return value: One of string, list, set, zset, hash, stream, or none.

Terminal window
127.0.0.1:6379> SET name "Alice"
OK
127.0.0.1:6379> TYPE name
string
127.0.0.1:6379> LPUSH mylist "a"
(integer) 1
127.0.0.1:6379> TYPE mylist
list

Find all keys matching a glob-style pattern. Use * to match all keys.

Syntax:

KEYS pattern

Return value: An array of matching keys.

Terminal window
127.0.0.1:6379> SET user:1 "Alice"
OK
127.0.0.1:6379> SET user:2 "Bob"
OK
127.0.0.1:6379> SET order:1 "pending"
OK
127.0.0.1:6379> KEYS user:*
1) "user:1"
2) "user:2"
127.0.0.1:6379> KEYS *
1) "user:1"
2) "user:2"
3) "order:1"

Incrementally iterate over keys using a cursor. Returns a new cursor and a batch of keys; pass the returned cursor to the next call until the cursor is 0.

Syntax:

SCAN cursor [MATCH pattern] [COUNT hint]

Return value: A two-element array: the next cursor and an array of keys.

Terminal window
127.0.0.1:6379> SCAN 0 MATCH user:* COUNT 100
1) "0"
2) 1) "user:1"
2) "user:2"

Get the remaining time to live (in seconds) for a key with an expiration.

Syntax:

TTL key

Return value: TTL in seconds, -1 if the key has no expiration, -2 if the key does not exist.

Terminal window
127.0.0.1:6379> SET session "abc" EX 300
OK
127.0.0.1:6379> TTL session
(integer) 300
127.0.0.1:6379> TTL permanent_key
(integer) -1

Get the remaining time to live in milliseconds.

Syntax:

PTTL key

Return value: TTL in milliseconds, -1 if no expiration, -2 if key does not exist.

Terminal window
127.0.0.1:6379> SET session "abc" PX 60000
OK
127.0.0.1:6379> PTTL session
(integer) 59985

Set an expiration (in seconds) on an existing key.

Syntax:

EXPIRE key seconds

Return value: 1 if the timeout was set, 0 if the key does not exist.

Terminal window
127.0.0.1:6379> SET mykey "hello"
OK
127.0.0.1:6379> EXPIRE mykey 60
(integer) 1
127.0.0.1:6379> TTL mykey
(integer) 60

Remove the expiration from a key, making it persist indefinitely.

Syntax:

PERSIST key

Return value: 1 if the timeout was removed, 0 if the key does not exist or had no timeout.

Terminal window
127.0.0.1:6379> SET temp "data" EX 100
OK
127.0.0.1:6379> PERSIST temp
(integer) 1
127.0.0.1:6379> TTL temp
(integer) -1

Rename a key. If the destination key already exists, it is overwritten.

Syntax:

RENAME key newkey

Return value: OK on success. Returns an error if the source key does not exist.

Terminal window
127.0.0.1:6379> SET old_name "value"
OK
127.0.0.1:6379> RENAME old_name new_name
OK
127.0.0.1:6379> GET new_name
"value"

Return a random key from the current database.

Syntax:

RANDOMKEY

Return value: A random key, or nil if the database is empty.

Terminal window
127.0.0.1:6379> RANDOMKEY
"user:1"

Publish/Subscribe messaging allows clients to subscribe to channels and receive messages published by other clients in real time.

Subscribe to one or more channels. The client enters a subscription mode and receives messages as they are published.

Syntax:

SUBSCRIBE channel [channel ...]

Return value: Subscription confirmation messages, then incoming messages as they arrive.

Terminal window
127.0.0.1:6379> SUBSCRIBE notifications alerts
Reading messages... (press Ctrl-C to quit)
1) "subscribe"
2) "notifications"
3) (integer) 1
1) "subscribe"
2) "alerts"
3) (integer) 2

Publish a message to a channel. All clients subscribed to that channel will receive it.

Syntax:

PUBLISH channel message

Return value: The number of clients that received the message.

Terminal window
127.0.0.1:6379> PUBLISH notifications "New order received"
(integer) 2

Unsubscribe from one or more channels. If no channels are specified, unsubscribe from all channels.

Syntax:

UNSUBSCRIBE [channel [channel ...]]

Return value: Unsubscription confirmation messages.

Terminal window
127.0.0.1:6379> UNSUBSCRIBE notifications
1) "unsubscribe"
2) "notifications"
3) (integer) 0

Redis transactions allow grouping multiple commands into an atomic unit. All commands between MULTI and EXEC are queued and executed together.

Start a transaction. Subsequent commands are queued until EXEC or DISCARD.

Syntax:

MULTI

Return value: OK.

Terminal window
127.0.0.1:6379> MULTI
OK
127.0.0.1:6379(TX)> SET balance:alice 100
QUEUED
127.0.0.1:6379(TX)> SET balance:bob 200
QUEUED
127.0.0.1:6379(TX)> EXEC
1) OK
2) OK

Execute all queued commands in the transaction.

Syntax:

EXEC

Return value: An array of results, one per queued command.

Terminal window
127.0.0.1:6379> MULTI
OK
127.0.0.1:6379(TX)> INCR counter
QUEUED
127.0.0.1:6379(TX)> INCR counter
QUEUED
127.0.0.1:6379(TX)> EXEC
1) (integer) 1
2) (integer) 2

Discard all queued commands and exit the transaction.

Syntax:

DISCARD

Return value: OK.

Terminal window
127.0.0.1:6379> MULTI
OK
127.0.0.1:6379(TX)> SET key "value"
QUEUED
127.0.0.1:6379(TX)> DISCARD
OK

Server commands provide administrative and diagnostic capabilities.

Test connectivity. Returns PONG or echoes the provided message.

Syntax:

PING [message]

Return value: PONG, or the provided message.

Terminal window
127.0.0.1:6379> PING
PONG
127.0.0.1:6379> PING "hello"
"hello"

Echo the given message back to the client.

Syntax:

ECHO message

Return value: The message.

Terminal window
127.0.0.1:6379> ECHO "ParticleDB"
"ParticleDB"

Close the connection.

Syntax:

QUIT

Return value: OK.

Terminal window
127.0.0.1:6379> QUIT
OK

Select the database by index. ParticleDB supports multiple logical databases (numbered 0-15 by default).

Syntax:

SELECT index

Return value: OK.

Terminal window
127.0.0.1:6379> SELECT 1
OK
127.0.0.1:6379[1]> SET key "in db 1"
OK

Return the number of keys in the currently selected database.

Syntax:

DBSIZE

Return value: The number of keys.

Terminal window
127.0.0.1:6379> DBSIZE
(integer) 42

Delete all keys in the currently selected database.

Syntax:

FLUSHDB

Return value: OK.

Terminal window
127.0.0.1:6379> FLUSHDB
OK
127.0.0.1:6379> DBSIZE
(integer) 0

Delete all keys in all databases.

Syntax:

FLUSHALL

Return value: OK.

Terminal window
127.0.0.1:6379> FLUSHALL
OK

Return server information and statistics. Optionally specify a section.

Syntax:

INFO [section]

Return value: A bulk string of server information.

Terminal window
127.0.0.1:6379> INFO server
# Server
particledb_version:0.1.0
tcp_port:6379
uptime_in_seconds:3600
...
127.0.0.1:6379> INFO memory
# Memory
used_memory:1048576
used_memory_human:1.00M
...

Get the value of a configuration parameter.

Syntax:

CONFIG GET parameter

Return value: An array of parameter name and value pairs. Supports glob patterns.

Terminal window
127.0.0.1:6379> CONFIG GET maxmemory
1) "maxmemory"
2) "0"
127.0.0.1:6379> CONFIG GET save
1) "save"
2) ""

Return the current server time as a two-element array: Unix timestamp in seconds and microseconds.

Syntax:

TIME

Return value: A two-element array of strings.

Terminal window
127.0.0.1:6379> TIME
1) "1679012345"
2) "678901"

Authenticate with the server. Required if the server is configured with a password.

Syntax:

AUTH password
AUTH username password

Return value: OK on success. Returns an error if the credentials are invalid.

Terminal window
127.0.0.1:6379> AUTH my_secret_password
OK
127.0.0.1:6379> AUTH admin my_secret_password
OK

  • All data structures share the same ACID storage engine as SQL tables. Writes through Redis commands are durable according to the configured WAL sync mode.
  • Data written via the Redis protocol is accessible through SQL, gRPC, HTTP, and WebSocket protocols, and vice versa.
  • For production workloads, use SCAN instead of KEYS to avoid blocking the server on large keyspaces.
  • Connection pooling from Redis client libraries (e.g., ioredis maxRetriesPerRequest, redis-py ConnectionPool) works as expected.