getrange 命令
Getrange 命令用于获取存储在指定 key 中字符串的子字符串。字符串的截取范围由 start 和 end 两个偏移量决定(包括 start 和 end 在内)。
语法
getrange KEY_NAME start end
返回值
截取得到的子字符串。
实例
设置 mykey 的值并截取字符串。
redis> SET mykey "This is my test key" OK redis> GETRANGE mykey 0 3 "This" redis> GETRANGE mykey 0 -1 "This is my test key"