]> git.saurik.com Git - redis.git/blame - doc/Lists.html
Fixed missed use of INSTALL_TOP
[redis.git] / doc / Lists.html
CommitLineData
8fb13ce8 1
2<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
3<html>
4 <head>
5 <link type="text/css" rel="stylesheet" href="style.css" />
6 </head>
7 <body>
8 <div id="page">
9
10 <div id='header'>
11 <a href="index.html">
12 <img style="border:none" alt="Redis Documentation" src="redis.png">
13 </a>
14 </div>
15
16 <div id="pagecontent">
17 <div class="index">
18<!-- This is a (PRE) block. Make sure it's left aligned or your toc title will be off. -->
19<b>Lists: Contents</b><br>&nbsp;&nbsp;<a href="#Redis List Type">Redis List Type</a><br>&nbsp;&nbsp;<a href="#Implementation details">Implementation details</a>
20 </div>
21
22 <h1 class="wikiname">Lists</h1>
23
24 <div class="summary">
25
26 </div>
27
28 <div class="narrow">
29 &iuml;&raquo;&iquest;#sidebar <a href="ListCommandsSidebar.html">ListCommandsSidebar</a><h1><a name="Redis List Type">Redis List Type</a></h1>Redis Lists are lists of <a href="Strings.html">Redis Strings</a>, 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.<br/><br/>The <a href="RpushCommand.html">LPUSH</a> command inserts a new elmenet on head, while <a href="RpushCommand.html">RPUSH</a> inserts a new element on tail. A new list is created when one of this operations is performed against an empty key.<br/><br/>For instance if perform the following operations:
30<pre class="codeblock python" name="code">
31LPUSH mylist a # now the list is &quot;a&quot;
32LPUSH mylist b # now the list is &quot;b&quot;,&quot;a&quot;
33RPUSH mylist c # now the list is &quot;b&quot;,&quot;a&quot;,&quot;c&quot; (RPUSH was used this time)
34</pre>
35The resulting list stored at <i>mylist</i> will contain the elements &quot;b&quot;,&quot;a&quot;,&quot;c&quot;.<br/><br/>The max length of a list is 232-1 elements (4294967295, more than 4 billion of elements per list).<h1><a name="Implementation details">Implementation details</a></h1>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). <a href="LrangeCommand.html">LRANGE</a> and <a href="LindexCommand.html">LINDEX</a> are examples of such commands.<br/><br/>The use of linked lists also guarantees that regardless of the length of the list pushing and popping are O(1) operations.<br/><br/>Redis Lists cache length information so <a href="LlenCommand.html">LLEN</a> is O(1) as well.
36 </div>
37
38 </div>
39 </div>
40 </body>
41</html>
42