Redis GETRANGE command is used to get the substring of the string value stored at the 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.
The function handles out of range requests by limiting the resulting range to the actual length of the string.
Simple string reply.
Following is the basic syntax of Redis GETRANGE command.
redis 127.0.0.1:6379> GETRANGE KEY_NAME start end
First, set a key in Redis and then get some part of it.
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"