GETRANGE

Since 1.1.0Strings

Syntax

GETRANGE key start stop
  • Flags: readonly
  • ACL categories: @read, @slow, @string
  • Arity: 4

Returns the bytes of the string at key from offset start to offset end, both included. Negative offsets count from the end: -1 is the last byte.

Reply

  • The bytes, as a bulk string.
  • An empty string if the range is outside the value, or the key does not exist.

Examples

> SET k "hello world"
OK
> GETRANGE k 0 4
"hello"
> GETRANGE k -5 -1
"world"
> GETRANGE k 100 200
""