SUBSTR (deprecated)

As of Redis version 2.0.0, this command is regarded as deprecated.

It can be replaced by GETRANGE when migrating or writing new code.

Syntax
SUBSTR key start end
Available since:
1.0.0
Time complexity:
O(N) where N is the length of the returned string. The complexity is ultimately determined by the returned length, but because creating a substring from an existing string is very cheap, it can be considered O(1) for small strings.
ACL categories:
@read, @string, @slow,

Returns the substring of the string value stored at key, determined by the offsets start and end (both are inclusive). Negative offsets can be used in order to provide an offset starting from the end of the string. So -1 means the last character, -2 the penultimate and so forth.

The function handles out of range requests by limiting the resulting range to the actual length of the string.

Examples

SET mykey "This is a string" GETRANGE mykey 0 3 GETRANGE mykey -3 -1 GETRANGE mykey 0 -1 GETRANGE mykey 10 100

RESP2/RESP3 Reply

Bulk string reply: the substring of the string value stored at key, determined by the offsets start and end (both are inclusive).
RATE THIS PAGE
Back to top ↑