SUBSTR (已弃用)
自 Redis 2.0.0 版本起,此命令被视为已弃用。
在迁移或编写新代码时,可以用GETRANGE
替换。
Syntax
SUBSTR key start end
- Available since:
- 1.0.0
- Time complexity:
- O(N) where N is the length of the returned string. The complexity is ultimately determined by the returned length, but because creating a substring from an existing string is very cheap, it can be considered O(1) for small strings.
- ACL categories:
-
@read
,@string
,@slow
,
返回存储在key
中的字符串值的子字符串,由偏移量start
和end
(两者都包括在内)确定。
可以使用负偏移量来提供从字符串末尾开始的偏移量。
因此,-1表示最后一个字符,-2表示倒数第二个字符,依此类推。
该函数通过将结果范围限制为字符串的实际长度来处理超出范围的请求。