LRANGE key start stop

Related commands

Available since 1.0.0.

Time complexity: O(S+N) where S is the start offset and N is the number of elements in the specified range.

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

Multi-bulk reply: 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>

redis命令之lrange的更多相关文章

  1. redis命令总结

     Redis命令总结 redis 127.0.0.1:6379> info  #查看server版本内存使用连接等信息 redis 127.0.0.1:6379> client list  ...

  2. Redis命令大全&中文解释&在线测试命令工具&在线中文文档

    在线测试命令地址:http://try.redis.io/ 官方文档:http://redis.io/commands http://redis.io/documentation Redis 命令参考 ...

  3. Redis命令

    redis的常用命令主要分为两个方面.一个是键值相关命令.一个是服务器相关命令(redis-cli进入终端) 1.键值相关命令 keys * 取出当前所有的key exists name 查看n是否有 ...

  4. Redis 命令总结

    Redis命令总结   连接操作相关的命令 quit:关闭连接(connection) auth:简单密码认证 持久化 save:将数据同步保存到磁盘 bgsave:将数据异步保存到磁盘 lastsa ...

  5. redis命令大全

    redis windows下使用及redis命令 Redis 是一个开源,高级的键值对的存储.它经常作为服务端的数据结构,它的键的数据类型能够是strings, hashs, lists, sets( ...

  6. 最全面的Redis命令行查阅手册(收藏查看)

    Redis是用C语言实现的,一般来说C语言实现的程序“距离”操作系统更近,执行速度相对会更快. Redis使用了单线程架构,预防了多线程可能产生的竞争问题. 作者对于Redis源代码可以说是精打细磨, ...

  7. redis命令参考和redis文档中文翻译版

    找到了一份redis的中文翻译文档,觉得适合学习和查阅.这份文档翻译的真的很良心啊,他是<Redis 设计与实现>一书的作者黄健宏翻译的. 地址:http://redisdoc.com/i ...

  8. redis命令大全参考手册

    redis功能强大,支持数据类型丰富,以下是redis操作命令大全,基本上涵盖了redis所有的命令,并附有解释说明,大家可以收藏.参考,你一定要知道的是:redis的key名要区分大小写,在redi ...

  9. Redis命令总结 (转)

    Redis命令总结   连接操作相关的命令 quit:关闭连接(connection) auth:简单密码认证 持久化 save:将数据同步保存到磁盘 bgsave:将数据异步保存到磁盘 lastsa ...

随机推荐

  1. Python prettytable的使用方法

    Python prettytable的使用方法 prettytable可以整齐地输出一个表格信息: +-----------+------+------------+----------------- ...

  2. 【BZOJ】1001: [BeiJing2006]狼抓兔子 Dinic算法求解平面图对偶图-最小割

    1001: [BeiJing2006]狼抓兔子 Description 左上角点为(1,1),右下角点为(N,M)(上图中N=4,M=5).有以下 三种类型的道路 1:(x,y)<==>( ...

  3. socket编程中用到的头文件整理

    socket编程中需要用到的头文件 sys/types.h:数据类型定义 sys/socket.h:提供socket函数及数据结构 netinet/in.h:定义数据结构sockaddr_in arp ...

  4. 制作进度条(UISlider)

    怎样判断是否应当使用进度条 用进度条的主要目的是为了用一根管子的充满程度来直观地表示某种数值的百分比,进度条分为可拖动和不可拖动两种. 可拖动进度条和不可拖动进度条的原理几乎是一模一样,唯一的区别是可 ...

  5. mysql数据库乱码

    问题:mysql数据库的编码都设置为utf8的情况下,用jdbc往数据库中插入数据时仍然乱码, 解决方法:在jdbc的中加上参数characterEncoding=utf8&useUnicod ...

  6. js构造函数传参

    1.直接传参并用this关键字初始化属性 function Person(name,age,learn){ this.name = name; this.age = age; this.learn = ...

  7. hbase 取多个版本数据

    http://jiajun.iteye.com/blog/945358 HBase如何存取多个版本的值? 废话少说,一般情况下使用Put的这个方法保存一个版本: /** * Add the speci ...

  8. web网页前端制作中的SEO方法

    在SEO盛行的今天到处都在谈优化,对于网站前端制作人员来说,有几点是跟SEO相关 的,也就是SEO站内优化中的一部分,下面总结几点: 1.title,.页面的标题,不用多说,这个必须有! 2.keyw ...

  9. java的装箱与拆箱

    在 JDK1.5 引入自动装箱和拆箱的机制后,包装类和基本类型之间的转换就更加轻松便利了.那什么是装箱和拆箱呢?我们分别来看下装箱:把基本类型转换成包装类,使其具有对象的性质,又可分为手动装箱和自动装 ...

  10. [DP] The 0-1 knapsack problem

    Give a dynamic-programming solution to the 0-1 knapsack problem that runs in O(nW) time, where n is ...