Easy Tutorial
❮ Transactions Unwatch Hashes Hincrby ❯

Redis Getrange Command

Redis Strings

The Redis Getrange command is used to get a substring of the string stored at a specified key. The substring's range is determined by the start and end offsets (including both start and end).

Syntax

The basic syntax of the redis Getrange command is as follows:

redis 127.0.0.1:6379> GETRANGE KEY_NAME start end

Available Versions

= 2.4.0

Return Value

The substring obtained.

Example

First, set the value of mykey and then get a substring.

redis 127.0.0.1:6379> SET mykey "This is my test key"
OK
redis 127.0.0.1:6379> GETRANGE mykey 0 3
"This"
redis 127.0.0.1:6379> GETRANGE mykey 0 -1
"This is my test key"

Redis Strings

❮ Transactions Unwatch Hashes Hincrby ❯