X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/43f30ac0f9bcc4a7afb06136a8dfe5b703be7935..59aee5513d27fdf2d24499f35611093fa0fab3fb:/doc/Lists.html diff --git a/doc/Lists.html b/doc/Lists.html index a79d9fd9..5f71937f 100644 --- a/doc/Lists.html +++ b/doc/Lists.html @@ -26,14 +26,13 @@
- #sidebar ListCommandsSidebar

Redis List Type

Redis Lists are lists of Redis Strings, sorted by insertion order. It's possible to add elements to a Redis List pushing new elements on the head (on the left) or on the tail (on the right) of the list.

The LPUSH command inserts a new elmenet on head, while RPUSH inserts a new element on tail. A new list is created when one of this operations is performed against an empty key.

For instance if perform the following operations: + #sidebar ListCommandsSidebar

Redis List Type

Redis Lists are lists of Redis Strings, sorted by insertion order. It's possible to add elements to a Redis List pushing new elements on the head (on the left) or on the tail (on the right) of the list.

The LPUSH command inserts a new elmenet on head, while RPUSH inserts a new element on tail. A new list is created when one of this operations is performed against an empty key.

For instance if perform the following operations:
 LPUSH mylist a   # now the list is "a"
 LPUSH mylist b   # now the list is "b","a"
 RPUSH mylist c   # now the list is "b","a","c" (RPUSH was used this time)
 
The resulting list stored at mylist will contain the elements "b","a","c".

The max length of a list is 232-1 elements (4294967295, more than 4 billion of elements per list).

Implementation details

Redis Lists are implemented as doubly liked lists. A few commands benefit from the fact the lists are doubly linked in order to reach the needed element starting from the nearest extreme (head or tail). LRANGE and LINDEX are examples of such commands.

The use of linked lists also guarantees that regardless of the length of the list pushing and popping are O(1) operations.

Redis Lists cache length information so LLEN is O(1) as well. -