diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2020-03-21 10:28:17 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-02-07 11:16:53 +0000 |
commit | 06cba6ccd165ca8b224797e37fccb9e63f026d77 (patch) | |
tree | e82f1bc439997ae296f2e74f8a64d84c5d95f140 /iredis/data/commands/lrange.md | |
parent | Initial commit. (diff) | |
download | iredis-06cba6ccd165ca8b224797e37fccb9e63f026d77.tar.xz iredis-06cba6ccd165ca8b224797e37fccb9e63f026d77.zip |
Adding upstream version 1.9.1.upstream/1.9.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'iredis/data/commands/lrange.md')
-rw-r--r-- | iredis/data/commands/lrange.md | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/iredis/data/commands/lrange.md b/iredis/data/commands/lrange.md new file mode 100644 index 0000000..923b542 --- /dev/null +++ b/iredis/data/commands/lrange.md @@ -0,0 +1,37 @@ +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 + +@array-reply: list of elements in the specified range. + +@examples + +```cli +RPUSH mylist "one" +RPUSH mylist "two" +RPUSH mylist "three" +LRANGE mylist 0 0 +LRANGE mylist -3 2 +LRANGE mylist -100 100 +LRANGE mylist 5 10 +``` |