Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Redis Getrange command

Redis Getrange command

Redis string

The Redis Getrange command is used to get a substring of the string stored in a specified key. The substring range is determined by the start and end offsets (inclusive of 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 Version

= 2.4.0

Return Value

The resulting substring.

Example

First, set the value of mykey and 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 string