PageRenderTime 9ms CodeModel.GetById 2ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 1ms

HTML | 47 lines | 37 code | 9 blank | 1 comment | 0 complexity | 8745aa79479a17476dc8590a6da9fd75 MD5 | raw file
 4    <head>
 5        <link type="text/css" rel="stylesheet" href="style.css" />
 6    </head>
 7    <body>
 8        <div id="page">
10            <div id='header'>
11            <a href="index.html">
12            <img style="border:none" alt="Redis Documentation" src="redis.png">
13            </a>
14            </div>
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>LtrimCommand: Contents</b><br>&nbsp;&nbsp;<a href="#LTRIM _key_ _start_ _end_">LTRIM _key_ _start_ _end_</a><br>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#Return value">Return value</a><br>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#See also">See also</a>
20                </div>
22                <h1 class="wikiname">LtrimCommand</h1>
24                <div class="summary">
26                </div>
28                <div class="narrow">
29                    <h1><a name="LTRIM _key_ _start_ _end_">LTRIM _key_ _start_ _end_</a></h1>
30<i>Time complexity: O(n) (with n being len of list - len of range)</i><blockquote>Trim an existing list so that it will contain only the specifiedrange of elements specified. Start and end are zero-based indexes.0 is the first element of the list (the list head), 1 the next elementand so on.</blockquote>
31<blockquote>For example LTRIM foobar 0 2 will modify the list stored at foobarkey so that only the first three elements of the list will remain.</blockquote>
32<blockquote>_start_ and <i>end</i> can also be negative numbers indicating offsetsfrom the end of the list. For example -1 is the last element ofthe list, -2 the penultimate element and so on.</blockquote>
33<blockquote>Indexes out of range will not produce an error: if start is overthe end of the list, or start &gt; end, an empty list is left as value.If end over the end of the list Redis will threat it just likethe last element of the list.</blockquote>
34<blockquote>Hint: the obvious use of LTRIM is together with LPUSH/RPUSH. For example:</blockquote>
35<pre class="codeblock python" name="code">
36        LPUSH mylist &lt;someelement&gt;
37        LTRIM mylist 0 99
38</pre><blockquote>The above two commands will push elements in the list taking care thatthe list will not grow without limits. This is very useful when usingRedis to store logs for example. It is important to note that when usedin this way LTRIM is an O(1) operation because in the average casejust one element is removed from the tail of the list.</blockquote>
39<h2><a name="Return value">Return value</a></h2><a href="ReplyTypes.html">Status code reply</a><h2><a name="See also">See also</a></h2>
40<ul><li> <a href="LlenCommand.html">LLEN</a></li><li> <a href="LrangeCommand.html">LRANGE</a></li><li> <a href="LtrimCommand.html">LTRIM</a></li><li> <a href="LdelCommand.html">LDEL</a></li><li> <a href="LindexCommand.html">LINDEX</a></li><li> <a href="LsetCommand.html">LSET</a></li></ul>
41                </div>
43            </div>
44        </div>
45    </body>