zoukankan      html  css  js  c++  java
  • redis命令之lrange

    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

    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> 
  • 相关阅读:
    HDU2795Biliboard
    Choose and Divide UVa10375 题解
    NKOJ2322: OSU!
    Git学习笔记(0)
    NKOJ2317 英语四六级考试
    NKOJ2321 东方project
    NKOJ2319 奇怪的班级 题解
    两点之间最短路径:弗洛伊德算法
    poj2524 Ubiquitous Religions
    SAP PA 共享 免费下载
  • 原文地址:https://www.cnblogs.com/vanishfan/p/3214573.html
Copyright © 2011-2022 走看看