wire / wire-format / redis-resp

Redis RESP (REdis Serialization Protocol)

Redis uses RESP (REdis Serialization Protocol), a text-based protocol. RESP3 (Redis 6+) adds new types. Types: Simple String (+...\r\n), Error (-...\r\n), Integer (:...\r\n), Bulk String ($len\r\n data \r\n), Array (*count\r\n ...), Null (_\r\n), Boolean (#t/f\r\n), Double (,...\r\n), Big Number (,...\r\n), Bulk Error (!len\r\n ...), Verbatim String (=len\r\n fmt:...), Map (%count\r\n), Set (~count\r\n), Attribute (|count\r\n), Push (>count\r\n).

wire-format kind wire-format status standard verification verified tier B wire-format@1

aka: Redis RESP (REdis Serialization Protocol)

wire format

spec: Redis protocol specification

Redis uses RESP (REdis Serialization Protocol), a text-based protocol. RESP3 (Redis 6+) adds new types. Types: Simple String (+...\r\n), Error (-...\r\n), Integer (:...\r\n), Bulk String ($len\r\n data \r\n), Array (*count\r\n ...), Null (_\r\n), Boolean (#t/f\r\n), Double (,...\r\n), Big Number (,...\r\n), Bulk Error (!len\r\n ...), Verbatim String (=len\r\n fmt:...), Map (%count\r\n), Set (~count\r\n), Attribute (|count\r\n), Push (>count\r\n).

fieldsizemeaning
Simple Stringvariable'+' + string + '\r\n'. No binary data, no newlines.
Errorvariable'-' + error message + '\r\n'.
Integervariable':' + integer + '\r\n'.
Bulk Stringvariable'$' + length + '\r\n' + data + '\r\n'. Length -1 = null.
Arrayvariable'*' + count + '\r\n' + elements. Count -1 = null.
Null (RESP3)3 bytes'_\r\n'.
Boolean (RESP3)4 bytes'#t\r\n' or '#f\r\n'.
Double (RESP3)variable',' + double + '\r\n' (e.g. ',3.14159\r\n' or ',inf\r\n').
Map (RESP3)variable'%' + count + '\r\n' + key-value pairs.
Set (RESP3)variable'~' + count + '\r\n' + elements.
Push (RESP3)variable'>' + count + '\r\n' + elements (for pub/sub messages).

example:

2a 32 0d 0a 24 34 0d 0a 50 49 4e 47 0d 0a 24 34 0d 0a 70 6f 6e 67 0d 0a

RESP Array: *2\r\n $4\r\n PING\r\n $4\r\n pong\r\n


provenance

agent: curl -H 'accept: application/json' wire.phall.io/wire-format/redis-resp or /wire-format/redis-resp.json