博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
redis命令之lrange
阅读量:5163 次
发布时间:2019-06-13

本文共 1619 字,大约阅读时间需要 5 分钟。

LRANGE key start stop

Related commands

Returns the specified elements of the list stored at key. The offsets start and stop are zero-based indexes, with 0 being the first element of the list (the head of the list), 1 being the next element and so on.

These offsets can also be negative numbers indicating offsets starting at the end of the list. For example, -1 is the last element of the list, -2 the penultimate, and so on.

Consistency with range functions in various programming languages

Note that if you have a list of numbers from 0 to 100, LRANGE list 0 10 will return 11 elements, that is, the rightmost item is included. This may or may not be consistent with behavior of range-related functions in your programming language of choice (think Ruby's Range.new,Array#slice or Python's range() function).

Out-of-range indexes

Out of range indexes will not produce an error. If start is larger than the end of the list, an empty list is returned. If stop is larger than the actual end of the list, Redis will treat it like the last element of the list.

Return value

: list of elements in the specified range.

Examples

redis> 
RPUSH mylist "one"
(integer) 1
redis> 
RPUSH mylist "two"
(integer) 2
redis> 
RPUSH mylist "three"
(integer) 3
redis> 
LRANGE mylist 0 0
1) "one"
redis> 
LRANGE mylist -3 2
1) "one"2) "two"3) "three"
redis> 
LRANGE mylist -100 100
1) "one"2) "two"3) "three"
redis> 
LRANGE mylist 5 10
(empty list or set)
redis> 

 

转载于:https://www.cnblogs.com/vanishfan/p/3214573.html

你可能感兴趣的文章
B. An express train to reveries(Round 418)
查看>>
不要逼孩子考100分
查看>>
Python(四)
查看>>
Symbols of String Pattern Matching
查看>>
如何判断一个人的能力
查看>>
【学习笔记】 狄利克雷与莫比乌斯
查看>>
关于 DataRow 中为 DataRowState.Deleted 状态的 字段列值取值方法
查看>>
724.Find Pivot Index
查看>>
小牛必会之—monkey
查看>>
python3.6.3安装步骤,适用linux centos系统
查看>>
没有终结点在侦听可以接受消息的*这通常是由于不正确的地址或者 SOAP操作导致的...
查看>>
HTML5---15.网络接口
查看>>
接收xml请求流并解析字符串的例子
查看>>
中文字符串分隔的注意问题
查看>>
zip打包是去掉路径
查看>>
常用的经典jquery代码[转]
查看>>
正则判断
查看>>
转--RTP如何打包H264数据
查看>>
IOC及AOP实现原理
查看>>
CocoaPods安装和使用教程
查看>>