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.
Connecting
Section titled “Connecting”# Connect with redis-cliredis-cli -p 6379
# Connect with authenticationredis-cli -p 6379 -a your_password
# Connect to a specific databaseredis-cli -p 6379 -n 0Any standard Redis client library (ioredis, redis-py, Jedis, etc.) works with ParticleDB’s RESP server.
Strings
Section titled “Strings”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]| Option | Description |
|---|---|
EX | Set expiration in seconds |
PX | Set expiration in milliseconds |
NX | Only set if the key does not already exist |
XX | Only set if the key already exists |
Return value: OK on success, nil if the condition (NX/XX) was not met.
127.0.0.1:6379> SET user:1:name "Alice"OK127.0.0.1:6379> SET session:abc token123 EX 3600OK127.0.0.1:6379> SET lock:order NX EX 30OKGet the value of a key.
Syntax:
GET keyReturn value: The value of the key, or nil if the key does not exist.
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 valueReturn value: 1 if the key was set, 0 if it already existed.
127.0.0.1:6379> SETNX mykey "Hello"(integer) 1127.0.0.1:6379> SETNX mykey "World"(integer) 0127.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 valueReturn value: OK.
127.0.0.1:6379> SETEX cache:page:home 300 "<html>...</html>"OK127.0.0.1:6379> TTL cache:page:home(integer) 300GETSET
Section titled “GETSET”Atomically set a key to a new value and return its old value.
Syntax:
GETSET key valueReturn value: The old value of the key, or nil if it did not exist.
127.0.0.1:6379> SET counter "10"OK127.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).
127.0.0.1:6379> SET key1 "a"OK127.0.0.1:6379> SET key2 "b"OK127.0.0.1:6379> MGET key1 key2 key31) "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).
127.0.0.1:6379> MSET user:1:name "Alice" user:1:email "alice@example.com"OK127.0.0.1:6379> MGET user:1:name user:1:email1) "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 keyReturn value: The value after the increment.
127.0.0.1:6379> SET visits 100OK127.0.0.1:6379> INCR visits(integer) 101127.0.0.1:6379> INCR visits(integer) 102Decrement the integer value of a key by one.
Syntax:
DECR keyReturn value: The value after the decrement.
127.0.0.1:6379> SET stock 50OK127.0.0.1:6379> DECR stock(integer) 49INCRBY
Section titled “INCRBY”Increment the integer value of a key by a specified amount.
Syntax:
INCRBY key incrementReturn value: The value after the increment.
127.0.0.1:6379> SET counter 10OK127.0.0.1:6379> INCRBY counter 5(integer) 15DECRBY
Section titled “DECRBY”Decrement the integer value of a key by a specified amount.
Syntax:
DECRBY key decrementReturn value: The value after the decrement.
127.0.0.1:6379> SET counter 100OK127.0.0.1:6379> DECRBY counter 25(integer) 75APPEND
Section titled “APPEND”Append a value to an existing string. If the key does not exist, it is created with the given value.
Syntax:
APPEND key valueReturn value: The length of the string after the append.
127.0.0.1:6379> SET greeting "Hello"OK127.0.0.1:6379> APPEND greeting " World"(integer) 11127.0.0.1:6379> GET greeting"Hello World"STRLEN
Section titled “STRLEN”Get the length of the string stored at a key.
Syntax:
STRLEN keyReturn value: The length of the string, or 0 if the key does not exist.
127.0.0.1:6379> SET name "ParticleDB"OK127.0.0.1:6379> STRLEN name(integer) 10Lists 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.
127.0.0.1:6379> LPUSH tasks "send email" "write report"(integer) 2127.0.0.1:6379> LRANGE tasks 0 -11) "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.
127.0.0.1:6379> RPUSH queue "job1" "job2" "job3"(integer) 3Remove and return the first element of a list.
Syntax:
LPOP keyReturn value: The removed element, or nil if the list is empty or does not exist.
127.0.0.1:6379> RPUSH queue "a" "b" "c"(integer) 3127.0.0.1:6379> LPOP queue"a"Remove and return the last element of a list.
Syntax:
RPOP keyReturn value: The removed element, or nil if the list is empty or does not exist.
127.0.0.1:6379> RPUSH stack "x" "y" "z"(integer) 3127.0.0.1:6379> RPOP stack"z"Get the number of elements in a list.
Syntax:
LLEN keyReturn value: The length of the list, or 0 if the key does not exist.
127.0.0.1:6379> RPUSH items "a" "b" "c"(integer) 3127.0.0.1:6379> LLEN items(integer) 3LRANGE
Section titled “LRANGE”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 stopReturn value: An array of elements in the specified range.
127.0.0.1:6379> RPUSH colors "red" "green" "blue" "yellow"(integer) 4127.0.0.1:6379> LRANGE colors 0 -11) "red"2) "green"3) "blue"4) "yellow"127.0.0.1:6379> LRANGE colors 1 21) "green"2) "blue"LINDEX
Section titled “LINDEX”Get an element by its index in a list.
Syntax:
LINDEX key indexReturn value: The element at the specified index, or nil if out of range.
127.0.0.1:6379> RPUSH letters "a" "b" "c"(integer) 3127.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 valueReturn value: OK on success. Returns an error if the index is out of range.
127.0.0.1:6379> RPUSH fruits "apple" "banana" "cherry"(integer) 3127.0.0.1:6379> LSET fruits 1 "blueberry"OK127.0.0.1:6379> LRANGE fruits 0 -11) "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).
127.0.0.1:6379> SADD tags "rust" "database" "olap"(integer) 3127.0.0.1:6379> SADD tags "rust"(integer) 0SMEMBERS
Section titled “SMEMBERS”Get all members of a set.
Syntax:
SMEMBERS keyReturn value: An array of all members.
127.0.0.1:6379> SADD colors "red" "blue" "green"(integer) 3127.0.0.1:6379> SMEMBERS colors1) "blue"2) "green"3) "red"SISMEMBER
Section titled “SISMEMBER”Test if a value is a member of a set.
Syntax:
SISMEMBER key memberReturn value: 1 if the member exists, 0 otherwise.
127.0.0.1:6379> SADD fruits "apple" "banana"(integer) 2127.0.0.1:6379> SISMEMBER fruits "apple"(integer) 1127.0.0.1:6379> SISMEMBER fruits "cherry"(integer) 0Remove one or more members from a set.
Syntax:
SREM key member [member ...]Return value: The number of members that were removed.
127.0.0.1:6379> SADD myset "a" "b" "c"(integer) 3127.0.0.1:6379> SREM myset "b"(integer) 1127.0.0.1:6379> SMEMBERS myset1) "a"2) "c"Get the number of members in a set.
Syntax:
SCARD keyReturn value: The cardinality (number of elements) of the set.
127.0.0.1:6379> SADD myset "a" "b" "c"(integer) 3127.0.0.1:6379> SCARD myset(integer) 3SUNION
Section titled “SUNION”Return the union of multiple sets.
Syntax:
SUNION key [key ...]Return value: An array of members in the resulting union.
127.0.0.1:6379> SADD set1 "a" "b" "c"(integer) 3127.0.0.1:6379> SADD set2 "b" "c" "d"(integer) 3127.0.0.1:6379> SUNION set1 set21) "a"2) "b"3) "c"4) "d"SINTER
Section titled “SINTER”Return the intersection of multiple sets.
Syntax:
SINTER key [key ...]Return value: An array of members present in all given sets.
127.0.0.1:6379> SADD set1 "a" "b" "c"(integer) 3127.0.0.1:6379> SADD set2 "b" "c" "d"(integer) 3127.0.0.1:6379> SINTER set1 set21) "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.
127.0.0.1:6379> SADD set1 "a" "b" "c"(integer) 3127.0.0.1:6379> SADD set2 "b" "c" "d"(integer) 3127.0.0.1:6379> SDIFF set1 set21) "a"Sorted Sets
Section titled “Sorted Sets”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).
127.0.0.1:6379> ZADD leaderboard 100 "alice" 85 "bob" 92 "charlie"(integer) 3ZSCORE
Section titled “ZSCORE”Get the score of a member in a sorted set.
Syntax:
ZSCORE key memberReturn value: The score as a string, or nil if the member does not exist.
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 memberReturn value: The rank as an integer, or nil if the member does not exist.
127.0.0.1:6379> ZADD leaderboard 100 "alice" 85 "bob" 92 "charlie"(integer) 3127.0.0.1:6379> ZRANK leaderboard "bob"(integer) 0127.0.0.1:6379> ZRANK leaderboard "alice"(integer) 2ZRANGE
Section titled “ZRANGE”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).
127.0.0.1:6379> ZADD leaderboard 100 "alice" 85 "bob" 92 "charlie"(integer) 3127.0.0.1:6379> ZRANGE leaderboard 0 -11) "bob"2) "charlie"3) "alice"127.0.0.1:6379> ZRANGE leaderboard 0 -1 WITHSCORES1) "bob"2) "85"3) "charlie"4) "92"5) "alice"6) "100"ZRANGEBYSCORE
Section titled “ZRANGEBYSCORE”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.
127.0.0.1:6379> ZADD temps 32.5 "NYC" 28.1 "LA" 35.0 "Phoenix" 22.3 "Seattle"(integer) 4127.0.0.1:6379> ZRANGEBYSCORE temps 25 331) "LA"2) "NYC"127.0.0.1:6379> ZRANGEBYSCORE temps -inf +inf WITHSCORES1) "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.
127.0.0.1:6379> ZADD scores 10 "a" 20 "b" 30 "c"(integer) 3127.0.0.1:6379> ZREM scores "b"(integer) 1Get the number of members in a sorted set.
Syntax:
ZCARD keyReturn value: The cardinality of the sorted set.
127.0.0.1:6379> ZADD scores 10 "a" 20 "b" 30 "c"(integer) 3127.0.0.1:6379> ZCARD scores(integer) 3Hashes
Section titled “Hashes”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).
127.0.0.1:6379> HSET user:1 name "Alice" email "alice@example.com" age "30"(integer) 3Get the value of a single field in a hash.
Syntax:
HGET key fieldReturn value: The value of the field, or nil if the field or key does not exist.
127.0.0.1:6379> HGET user:1 name"Alice"127.0.0.1:6379> HGET user:1 nonexistent(nil)HGETALL
Section titled “HGETALL”Get all fields and values in a hash.
Syntax:
HGETALL keyReturn value: An array of alternating field names and values.
127.0.0.1:6379> HSET user:1 name "Alice" email "alice@example.com"(integer) 2127.0.0.1:6379> HGETALL user:11) "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.
127.0.0.1:6379> HSET user:1 name "Alice" tmp "delete_me"(integer) 2127.0.0.1:6379> HDEL user:1 tmp(integer) 1HEXISTS
Section titled “HEXISTS”Check if a field exists in a hash.
Syntax:
HEXISTS key fieldReturn value: 1 if the field exists, 0 otherwise.
127.0.0.1:6379> HSET user:1 name "Alice"(integer) 1127.0.0.1:6379> HEXISTS user:1 name(integer) 1127.0.0.1:6379> HEXISTS user:1 phone(integer) 0Get all field names in a hash.
Syntax:
HKEYS keyReturn value: An array of field names.
127.0.0.1:6379> HSET config host "localhost" port "6379"(integer) 2127.0.0.1:6379> HKEYS config1) "host"2) "port"Get all values in a hash.
Syntax:
HVALS keyReturn value: An array of values.
127.0.0.1:6379> HSET config host "localhost" port "6379"(integer) 2127.0.0.1:6379> HVALS config1) "localhost"2) "6379"Get the number of fields in a hash.
Syntax:
HLEN keyReturn value: The number of fields.
127.0.0.1:6379> HSET user:1 name "Alice" email "alice@example.com" age "30"(integer) 3127.0.0.1:6379> HLEN user:1(integer) 3HINCRBY
Section titled “HINCRBY”Increment the integer value of a hash field by a given amount.
Syntax:
HINCRBY key field incrementReturn value: The value after the increment.
127.0.0.1:6379> HSET user:1 login_count 10(integer) 1127.0.0.1:6379> HINCRBY user:1 login_count 1(integer) 11Set 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.
127.0.0.1:6379> HMSET user:2 name "Bob" email "bob@example.com"OKGet 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).
127.0.0.1:6379> HSET user:1 name "Alice" email "alice@example.com" age "30"(integer) 3127.0.0.1:6379> HMGET user:1 name age phone1) "Alice"2) "30"3) (nil)HSETNX
Section titled “HSETNX”Set the value of a hash field only if the field does not already exist.
Syntax:
HSETNX key field valueReturn value: 1 if the field was set, 0 if it already existed.
127.0.0.1:6379> HSETNX user:1 name "Alice"(integer) 1127.0.0.1:6379> HSETNX user:1 name "Bob"(integer) 0127.0.0.1:6379> HGET user:1 name"Alice"Streams
Section titled “Streams”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.
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 keyReturn value: The number of entries.
127.0.0.1:6379> XLEN events(integer) 2XRANGE
Section titled “XRANGE”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.
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 11) 1) "1679012345678-0" 2) 1) "action" 2) "click" 3) "page" 4) "/home"XREVRANGE
Section titled “XREVRANGE”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.
127.0.0.1:6379> XREVRANGE events + - COUNT 11) 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.
# Read up to 10 entries from "events" starting after ID 0127.0.0.1:6379> XREAD COUNT 10 STREAMS events 01) 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 entries127.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 [~] countUse ~ for approximate trimming (more efficient, may keep slightly more entries).
Return value: The number of entries removed.
127.0.0.1:6379> XTRIM events MAXLEN 1000(integer) 0127.0.0.1:6379> XTRIM events MAXLEN ~ 1000(integer) 0XINFO STREAM
Section titled “XINFO STREAM”Get information about a stream.
Syntax:
XINFO STREAM keyReturn value: A detailed map of stream metadata including length, first/last entry, and radix tree statistics.
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.
127.0.0.1:6379> SET a 1OK127.0.0.1:6379> SET b 2OK127.0.0.1:6379> DEL a b nonexistent(integer) 2EXISTS
Section titled “EXISTS”Check if one or more keys exist.
Syntax:
EXISTS key [key ...]Return value: The number of specified keys that exist.
127.0.0.1:6379> SET mykey "hello"OK127.0.0.1:6379> EXISTS mykey(integer) 1127.0.0.1:6379> EXISTS mykey otherkey(integer) 1Get the data type of a key.
Syntax:
TYPE keyReturn value: One of string, list, set, zset, hash, stream, or none.
127.0.0.1:6379> SET name "Alice"OK127.0.0.1:6379> TYPE namestring127.0.0.1:6379> LPUSH mylist "a"(integer) 1127.0.0.1:6379> TYPE mylistlistFind all keys matching a glob-style pattern. Use * to match all keys.
Syntax:
KEYS patternReturn value: An array of matching keys.
127.0.0.1:6379> SET user:1 "Alice"OK127.0.0.1:6379> SET user:2 "Bob"OK127.0.0.1:6379> SET order:1 "pending"OK127.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.
127.0.0.1:6379> SCAN 0 MATCH user:* COUNT 1001) "0"2) 1) "user:1" 2) "user:2"Get the remaining time to live (in seconds) for a key with an expiration.
Syntax:
TTL keyReturn value: TTL in seconds, -1 if the key has no expiration, -2 if the key
does not exist.
127.0.0.1:6379> SET session "abc" EX 300OK127.0.0.1:6379> TTL session(integer) 300127.0.0.1:6379> TTL permanent_key(integer) -1Get the remaining time to live in milliseconds.
Syntax:
PTTL keyReturn value: TTL in milliseconds, -1 if no expiration, -2 if key does not exist.
127.0.0.1:6379> SET session "abc" PX 60000OK127.0.0.1:6379> PTTL session(integer) 59985EXPIRE
Section titled “EXPIRE”Set an expiration (in seconds) on an existing key.
Syntax:
EXPIRE key secondsReturn value: 1 if the timeout was set, 0 if the key does not exist.
127.0.0.1:6379> SET mykey "hello"OK127.0.0.1:6379> EXPIRE mykey 60(integer) 1127.0.0.1:6379> TTL mykey(integer) 60PERSIST
Section titled “PERSIST”Remove the expiration from a key, making it persist indefinitely.
Syntax:
PERSIST keyReturn value: 1 if the timeout was removed, 0 if the key does not exist or had
no timeout.
127.0.0.1:6379> SET temp "data" EX 100OK127.0.0.1:6379> PERSIST temp(integer) 1127.0.0.1:6379> TTL temp(integer) -1RENAME
Section titled “RENAME”Rename a key. If the destination key already exists, it is overwritten.
Syntax:
RENAME key newkeyReturn value: OK on success. Returns an error if the source key does not exist.
127.0.0.1:6379> SET old_name "value"OK127.0.0.1:6379> RENAME old_name new_nameOK127.0.0.1:6379> GET new_name"value"RANDOMKEY
Section titled “RANDOMKEY”Return a random key from the current database.
Syntax:
RANDOMKEYReturn value: A random key, or nil if the database is empty.
127.0.0.1:6379> RANDOMKEY"user:1"Pub/Sub
Section titled “Pub/Sub”Publish/Subscribe messaging allows clients to subscribe to channels and receive messages published by other clients in real time.
SUBSCRIBE
Section titled “SUBSCRIBE”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.
127.0.0.1:6379> SUBSCRIBE notifications alertsReading messages... (press Ctrl-C to quit)1) "subscribe"2) "notifications"3) (integer) 11) "subscribe"2) "alerts"3) (integer) 2PUBLISH
Section titled “PUBLISH”Publish a message to a channel. All clients subscribed to that channel will receive it.
Syntax:
PUBLISH channel messageReturn value: The number of clients that received the message.
127.0.0.1:6379> PUBLISH notifications "New order received"(integer) 2UNSUBSCRIBE
Section titled “UNSUBSCRIBE”Unsubscribe from one or more channels. If no channels are specified, unsubscribe from all channels.
Syntax:
UNSUBSCRIBE [channel [channel ...]]Return value: Unsubscription confirmation messages.
127.0.0.1:6379> UNSUBSCRIBE notifications1) "unsubscribe"2) "notifications"3) (integer) 0Transactions
Section titled “Transactions”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:
MULTIReturn value: OK.
127.0.0.1:6379> MULTIOK127.0.0.1:6379(TX)> SET balance:alice 100QUEUED127.0.0.1:6379(TX)> SET balance:bob 200QUEUED127.0.0.1:6379(TX)> EXEC1) OK2) OKExecute all queued commands in the transaction.
Syntax:
EXECReturn value: An array of results, one per queued command.
127.0.0.1:6379> MULTIOK127.0.0.1:6379(TX)> INCR counterQUEUED127.0.0.1:6379(TX)> INCR counterQUEUED127.0.0.1:6379(TX)> EXEC1) (integer) 12) (integer) 2DISCARD
Section titled “DISCARD”Discard all queued commands and exit the transaction.
Syntax:
DISCARDReturn value: OK.
127.0.0.1:6379> MULTIOK127.0.0.1:6379(TX)> SET key "value"QUEUED127.0.0.1:6379(TX)> DISCARDOKServer
Section titled “Server”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.
127.0.0.1:6379> PINGPONG127.0.0.1:6379> PING "hello""hello"Echo the given message back to the client.
Syntax:
ECHO messageReturn value: The message.
127.0.0.1:6379> ECHO "ParticleDB""ParticleDB"Close the connection.
Syntax:
QUITReturn value: OK.
127.0.0.1:6379> QUITOKSELECT
Section titled “SELECT”Select the database by index. ParticleDB supports multiple logical databases (numbered 0-15 by default).
Syntax:
SELECT indexReturn value: OK.
127.0.0.1:6379> SELECT 1OK127.0.0.1:6379[1]> SET key "in db 1"OKDBSIZE
Section titled “DBSIZE”Return the number of keys in the currently selected database.
Syntax:
DBSIZEReturn value: The number of keys.
127.0.0.1:6379> DBSIZE(integer) 42FLUSHDB
Section titled “FLUSHDB”Delete all keys in the currently selected database.
Syntax:
FLUSHDBReturn value: OK.
127.0.0.1:6379> FLUSHDBOK127.0.0.1:6379> DBSIZE(integer) 0FLUSHALL
Section titled “FLUSHALL”Delete all keys in all databases.
Syntax:
FLUSHALLReturn value: OK.
127.0.0.1:6379> FLUSHALLOKReturn server information and statistics. Optionally specify a section.
Syntax:
INFO [section]Return value: A bulk string of server information.
127.0.0.1:6379> INFO server# Serverparticledb_version:0.1.0tcp_port:6379uptime_in_seconds:3600...
127.0.0.1:6379> INFO memory# Memoryused_memory:1048576used_memory_human:1.00M...CONFIG GET
Section titled “CONFIG GET”Get the value of a configuration parameter.
Syntax:
CONFIG GET parameterReturn value: An array of parameter name and value pairs. Supports glob patterns.
127.0.0.1:6379> CONFIG GET maxmemory1) "maxmemory"2) "0"127.0.0.1:6379> CONFIG GET save1) "save"2) ""Return the current server time as a two-element array: Unix timestamp in seconds and microseconds.
Syntax:
TIMEReturn value: A two-element array of strings.
127.0.0.1:6379> TIME1) "1679012345"2) "678901"Authenticate with the server. Required if the server is configured with a password.
Syntax:
AUTH passwordAUTH username passwordReturn value: OK on success. Returns an error if the credentials are invalid.
127.0.0.1:6379> AUTH my_secret_passwordOK127.0.0.1:6379> AUTH admin my_secret_passwordOK- 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
SCANinstead ofKEYSto avoid blocking the server on large keyspaces. - Connection pooling from Redis client libraries (e.g., ioredis
maxRetriesPerRequest, redis-pyConnectionPool) works as expected.