X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/924aa408b99837036b679bd3895f836af6bc763f..4eddb121563a9e50cf2ee66e2a0ff7c186dd696a:/doc/Lists.html diff --git a/doc/Lists.html b/doc/Lists.html new file mode 100644 index 00000000..5f71937f --- /dev/null +++ b/doc/Lists.html @@ -0,0 +1,42 @@ + + + + + + + +
+ + + +
+
+ +Lists: Contents
  Redis List Type
  Implementation details +
+ +

Lists

+ +
+ +
+ +
+ #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. +
+ +
+
+ + +