Skip to content

Ask the HotKV docs

Answers come only from these docs and can be wrong; check the linked pages before you rely on them.

SUBSTR

Last updated

Deprecated: use GETRANGE instead.

SUBSTR key start end
Group
String
Complexity
O(N) where N is the length of the returned substring
Arity
4 (exactly, counting the command name)
Flags
read-only
Keys
first 1, last 1, step 1
HotKV Cloud
All plans
On-Premise
no license needed

SUBSTR is an older name for GETRANGE and behaves the same way: it returns the bytes from start to end, both included, with negative offsets counting from the end. Use GETRANGE in new code.

Case RESP2 RESP3
Always Bulk string: the substring (possibly empty) Bulk string

The errors are those of GETRANGE.

127.0.0.1:6379> SET phrase "hotkv rocks"
OK
127.0.0.1:6379> SUBSTR phrase 0 4
"hotkv"

Same as Redis 7 and Valkey 8, where it is also deprecated.

GETRANGE, STRLEN