GETRANGE key start end
自2.4.0可用 时间复杂度:
警告:此命令被重命令以GETRANGE,它在Redis2.0版本这前称作SUBSTR
返回字符串的子串,取决于偏移量start和end(包括start和end)。负的偏移量可以用来表示距字符串结尾的偏移量。因此-1表示最后一个字符,-2表示倒数第二个字符等等。
这个函数在处理超出范围的请求时都会把他限制为字符串的实际长度
返回值
Bulk string reply
示例
redis> SET mykey "This is a string"
"OK"
redis> GETRANGE mykey 0 3
"This"
redis> GETRANGE mykey -3 -1
"ing"
redis> GETRANGE mykey 0 -1
"This is a string"
redis> GETRANGE mykey 10 100
"string"
redis>