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"

  1. (integer) 1

redis> RPUSH mylist "two"

  1. (integer) 2

redis> RPUSH mylist "three"

  1. (integer) 3

redis> LRANGE mylist 0 0

  1. 1) "one"

redis> LRANGE mylist -3 2

  1. 1) "one"
  2. 2) "two"
  3. 3) "three"

redis> LRANGE mylist -100 100

  1. 1) "one"
  2. 2) "two"
  3. 3) "three"

redis> LRANGE mylist 5 10

  1. (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. DB2实用命令记录

    quiesce tablespace quiesce tablespaces for table <table_name> share; Monitor Switches details ...

  2. [Python][flask][flask-login]关于flask-login中各种API使用实例

    本篇博文跟上一篇[Python][flask][flask-wtf]关于flask-wtf中API使用实例教程有莫大的关系. 简介:Flask-Login 为 Flask 提供了用户会话管理.它处理了 ...

  3. SQL学习_时间函数

    最近测试报表需要统计不同时间段的列表记录,收集一些时间函数作为参考,原文地址:http://blog.csdn.net/lyzlyfok/article/details/6282509 sql ser ...

  4. Git常用命令汇总

    1.初始化相关 git init 初始化仓库 git remove add origin url 添加仓库地址 git remove rm origin 删除仓库地址 git clone 克隆别人的分 ...

  5. 【jpa】 引用包的问题

    Hibernate使用Annotation(注解)需加                         hibernate-jpa-2.0-api-1.0.0.Final.jar Hibernate3 ...

  6. JavaScript闭包底层解析

    1. 闭包是一个函数,这个函数有权访问另一个函数作用域中的变量,创建闭包最常见的方式,就是在函数内部创建函数.要想彻底搞清其中细节,必须从函数从创建到调用的时候都发生了什么入手 2. 函数第一次被调用 ...

  7. Ubuntu之网络配置

    一.配置大概分三类:通过配置文件配置.通过命令配置.通过图形化的网络连接菜单配置. 拨号无线等的没条件实验,不涉及. 主要文件:/etc/network/interfaces,这里是IP.网关.掩码等 ...

  8. javaScript Code 用javascript确定每月第二个星期五

    废话少说只就上Code:     说明:getDay()方法获取星期(这里的星期是从0到6).参见:http://www.w3school.com.cn/js/js_obj_date.asp 中的ge ...

  9. android 发送自定义广播以及接收自定义广播

    发送自定义广播程序: 布局文件: <?xml version="1.0" encoding="utf-8"?> <LinearLayout x ...

  10. cocos2d-x mac or windows eclipse android ------ Eclipse工程里面还会有许多警告

    由于公司的游戏项目比较特殊,  coco2d-x 的  ios  和  android  的游戏 代码 没有采用 共享目录的开发方式.所以android 内的 c++ 游戏代码全部放在 jni 下, ...