Integer
RESP2prefix: : · client type: Integer / int / Long
Integers use the : prefix and represent a signed 64-bit integer value. Used for command results that are naturally numeric: INCR/DECR return values, LLEN/SCARD counts, EXPIRE success/failure (1/0), PUBLISH subscriber count. The special values 0 and 1 are also used as boolean equivalents for commands that return success/failure.
Details
Integer replies have the format :<number>\r\n. The number is in the signed 64-bit range (–9,223,372,036,854,775,808 to 9,223,372,036,854,775,807).
Booleans in RESP2: Redis uses 1 for true/success and 0 for false/failure in commands like EXISTS, EXPIRE, SISMEMBER, HEXISTS. Clients must know which commands return boolean-semantic integers vs actual counts.
In RESP3: integers remain for count replies. Boolean values now use the dedicated # boolean type (SISMEMBER returns #t or #f). Double values use the , type. Large integers outside 64-bit range use the ( big number type.
Common integer reply commands: INCR, DECR, INCRBY – returns new value LLEN, SCARD, HLEN, ZCARD – collection size APPEND – new string length SETRANGE – string length after write PUBLISH – number of subscribers that received the message
Wire encoding
:42\r\n :0\r\n :1\r\n :-5\r\n
Type information
| Prefix byte | : |
| Version | RESP2 |
| Client type | Integer / int / Long |
| Specification | RESP3 specification (GitHub) → |