Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

GETRANGE

Josh Baker edited this page Oct 11, 2016 · 7 revisions

GETRANGE key start end

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.

##Return value Bulk string reply

##Examples

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

Related Commands

APPEND, BITCOUNT, BITOP, BITPOS, DBSIZE, DECR, DECRBY, DEL, EXISTS, EXPIRE, EXPIREAT, FLUSHDB, GET, GETBIT, GETRANGE, GETSET, INCR, INCRBY, INCRBYFLOAT, KEYS, MGET, MSET, MSETNX, PDEL, PERSIST, PEXPIRE, PEXPIREAT, PTTL, RENAME, RENAMENX, SET, SETBIT, SETRANGE, STRLEN, TTL

Clone this wiki locally