url
stringlengths
38
157
content
stringlengths
72
15.1M
https://redis.io/docs/latest/integrate/write-behind/reference/data-transformation-block-types/.html
<section class="prose w-full py-12 max-w-none"> <h1> Data transformation block types </h1> <p class="text-lg -mt-5 mb-10"> Data transformation block type reference </p> <nav> <a href="/docs/latest/integrate/write-behind/reference/data-transformation-block-types/add_field/"> add_field </a> <p> Add fields to a record </p> <a href="/docs/latest/integrate/write-behind/reference/data-transformation-block-types/cassandra_write/"> cassandra.write </a> <p> Write into a Cassandra data store </p> <a href="/docs/latest/integrate/write-behind/reference/data-transformation-block-types/filter/"> filter </a> <p> Filter records </p> <a href="/docs/latest/integrate/write-behind/reference/data-transformation-block-types/key/"> key </a> <p> Set the Redis key for this data entry </p> <a href="/docs/latest/integrate/write-behind/reference/data-transformation-block-types/map/"> map </a> <p> Map a record into a new output based on expressions </p> <a href="/docs/latest/integrate/write-behind/reference/data-transformation-block-types/redis_write/"> redis.write </a> <p> Write to a Redis Enterprise database </p> <a href="/docs/latest/integrate/write-behind/reference/data-transformation-block-types/relational_write/"> relational.write </a> <p> Write into a SQL-compatible data store </p> <a href="/docs/latest/integrate/write-behind/reference/data-transformation-block-types/remove_field/"> remove_field </a> <p> Remove fields </p> <a href="/docs/latest/integrate/write-behind/reference/data-transformation-block-types/rename_field/"> rename_field </a> <p> Rename fields. All other fields remain unchanged. </p> </nav> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/integrate/write-behind/reference/data-transformation-block-types/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/pfselftest/.html
<section class="prose w-full py-12"> <h1 class="command-name"> PFSELFTEST </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">PFSELFTEST</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available since: </dt> <dd class="m-0"> 2.8.9 </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> N/A </dd> <dt class="font-semibold text-redis-ink-900 m-0"> ACL categories: </dt> <dd class="m-0"> <code> @hyperloglog </code> <span class="mr-1 last:hidden"> , </span> <code> @admin </code> <span class="mr-1 last:hidden"> , </span> <code> @slow </code> <span class="mr-1 last:hidden"> , </span> <code> @dangerous </code> <span class="mr-1 last:hidden"> , </span> </dd> </dl> <p> The <code> PFSELFTEST </code> command is an internal command. It is meant to be used for developing and testing Redis. </p> <h2 id="resp2resp3-reply"> RESP2/RESP3 Reply </h2> <a href="../../develop/reference/protocol-spec#simple-strings"> Simple string reply </a> : <code> OK </code> . <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/pfselftest/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/develop/connect/clients/.html
<section class="prose w-full py-12 max-w-none"> <h1> Connect with Redis client API libraries </h1> <p class="text-lg -mt-5 mb-10"> Connect your application to a Redis database and try an example </p> <p> Use the Redis client libraries to connect to Redis servers from your own code. We document the following client libraries for six main languages: </p> <table> <thead> <tr> <th style="text-align:left"> Language </th> <th style="text-align:left"> Client name </th> <th style="text-align:left"> Docs </th> <th style="text-align:left"> Supported </th> </tr> </thead> <tbody> <tr> <td style="text-align:left"> <a href="https://www.python.org/"> Python </a> </td> <td style="text-align:left"> <a href="https://github.com/redis/redis-py"> <code> redis-py </code> </a> </td> <td style="text-align:left"> <a href="/docs/latest/develop/clients/redis-py/"> <code> redis-py </code> guide </a> </td> <td style="text-align:left"> Yes </td> </tr> <tr> <td style="text-align:left"> <a href="https://www.python.org/"> Python </a> </td> <td style="text-align:left"> <a href="https://github.com/redis/redis-vl-python"> <code> RedisVL </code> </a> </td> <td style="text-align:left"> <a href="/docs/latest/integrate/redisvl/"> RedisVL guide </a> </td> <td style="text-align:left"> Yes </td> </tr> <tr> <td style="text-align:left"> <a href="https://learn.microsoft.com/en-us/dotnet/csharp/"> C#/.NET </a> </td> <td style="text-align:left"> <a href="https://github.com/redis/NRedisStack"> <code> NRedisStack </code> </a> </td> <td style="text-align:left"> <a href="/docs/latest/develop/clients/dotnet/"> <code> NRedisStack </code> guide </a> </td> <td style="text-align:left"> Yes </td> </tr> <tr> <td style="text-align:left"> <a href="https://nodejs.org/en"> JavaScript </a> </td> <td style="text-align:left"> <a href="https://github.com/redis/node-redis"> <code> node-redis </code> </a> </td> <td style="text-align:left"> <a href="/docs/latest/develop/clients/nodejs/"> <code> node-redis </code> guide </a> </td> <td style="text-align:left"> Yes </td> </tr> <tr> <td style="text-align:left"> <a href="https://www.java.com/en/"> Java </a> </td> <td style="text-align:left"> <a href="https://github.com/redis/jedis"> <code> Jedis </code> </a> </td> <td style="text-align:left"> <a href="/docs/latest/develop/clients/jedis/"> <code> Jedis </code> guide </a> </td> <td style="text-align:left"> Yes </td> </tr> <tr> <td style="text-align:left"> <a href="https://www.java.com/en/"> Java </a> </td> <td style="text-align:left"> <a href="https://github.com/redis/lettuce"> <code> Lettuce </code> </a> </td> <td style="text-align:left"> <a href="/docs/latest/develop/clients/lettuce/"> <code> Lettuce </code> guide </a> </td> <td style="text-align:left"> Yes </td> </tr> <tr> <td style="text-align:left"> <a href="https://go.dev/"> Go </a> </td> <td style="text-align:left"> <a href="https://github.com/redis/go-redis"> <code> go-redis </code> </a> </td> <td style="text-align:left"> <a href="/docs/latest/develop/clients/go/"> <code> go-redis </code> guide </a> </td> <td style="text-align:left"> Yes </td> </tr> <tr> <td style="text-align:left"> <a href="https://www.php.net/"> PHP </a> </td> <td style="text-align:left"> <a href="https://github.com/predis/predis"> <code> Predis </code> </a> </td> <td style="text-align:left"> <a href="/docs/latest/develop/clients/php/"> <code> Predis </code> guide </a> </td> <td style="text-align:left"> No </td> </tr> </tbody> </table> <p> We also provide several higher-level <a href="/docs/latest/develop/clients/om-clients/"> object mapping (OM) </a> libraries for <a href="/docs/latest/integrate/redisom-for-python/"> Python </a> , <a href="/docs/latest/integrate/redisom-for-net/"> C#/.NET </a> , <a href="/docs/latest/integrate/redisom-for-node-js/"> Node.js </a> , and <a href="/docs/latest/integrate/redisom-for-java/"> Java/Spring </a> . </p> <h2 id="community-supported-clients"> Community-supported clients </h2> <p> The table below shows the recommended third-party client libraries for languages that Redis does not document directly: </p> <table> <thead> <tr> <th style="text-align:left"> Language </th> <th style="text-align:left"> Client name </th> <th style="text-align:left"> Github </th> <th style="text-align:left"> Docs </th> </tr> </thead> <tbody> <tr> <td style="text-align:left"> C </td> <td style="text-align:left"> hiredis </td> <td style="text-align:left"> <a href="https://github.com/redis/hiredis"> https://github.com/redis/hiredis </a> </td> <td style="text-align:left"> <a href="https://github.com/redis/hiredis"> https://github.com/redis/hiredis </a> </td> </tr> <tr> <td style="text-align:left"> <a href="https://www.php.net/"> PHP </a> </td> <td style="text-align:left"> PhpRedis extension </td> <td style="text-align:left"> <a href="https://github.com/phpredis/phpredis"> https://github.com/phpredis/phpredis </a> </td> <td style="text-align:left"> <a href="https://github.com/phpredis/phpredis/blob/develop/README.md"> https://github.com/phpredis/phpredis/blob/develop/README.md </a> </td> </tr> <tr> <td style="text-align:left"> <a href="https://www.ruby-lang.org/en/"> Ruby </a> </td> <td style="text-align:left"> redis-rb </td> <td style="text-align:left"> <a href="https://github.com/redis/redis-rb"> https://github.com/redis/redis-rb </a> </td> <td style="text-align:left"> <a href="https://rubydoc.info/gems/redis"> https://rubydoc.info/gems/redis </a> </td> </tr> <tr> <td style="text-align:left"> <a href="https://www.rust-lang.org/"> Rust </a> </td> <td style="text-align:left"> redis-rs </td> <td style="text-align:left"> <a href="https://github.com/redis-rs/redis-rs"> https://github.com/redis-rs/redis-rs </a> </td> <td style="text-align:left"> <a href="https://docs.rs/redis/latest/redis/"> https://docs.rs/redis/latest/redis/ </a> </td> </tr> <tr> <td style="text-align:left"> <a href="https://en.wikipedia.org/wiki/C%2B%2B"> C++ </a> </td> <td style="text-align:left"> Boost.Redis </td> <td style="text-align:left"> <a href="https://github.com/boostorg/redis"> https://github.com/boostorg/redis </a> </td> <td style="text-align:left"> <a href="https://www.boost.org/doc/libs/develop/libs/redis/doc/html/index.html"> https://www.boost.org/doc/libs/develop/libs/redis/doc/html/index.html </a> </td> </tr> </tbody> </table> <h2 id="requirements"> Requirements </h2> <p> You will need access to a Redis server to use these libraries. You can experiment with a local installation of Redis Stack (see <a href="/docs/latest/operate/oss_and_stack/install/install-stack/"> Install Redis Stack </a> ) or with a free trial of <a href="/docs/latest/operate/rc/"> Redis Cloud </a> . To interact with a Redis server without writing code, use the <a href="/docs/latest/develop/tools/cli/"> Redis CLI </a> and <a href="/docs/latest/develop/tools/insight/"> Redis Insight </a> tools. </p> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/develop/clients/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/xinfo-stream/.html
<section class="prose w-full py-12"> <h1 class="command-name"> XINFO STREAM </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">XINFO STREAM key [FULL [COUNT count]]</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available since: </dt> <dd class="m-0"> 5.0.0 </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(1) </dd> <dt class="font-semibold text-redis-ink-900 m-0"> ACL categories: </dt> <dd class="m-0"> <code> @read </code> <span class="mr-1 last:hidden"> , </span> <code> @stream </code> <span class="mr-1 last:hidden"> , </span> <code> @slow </code> <span class="mr-1 last:hidden"> , </span> </dd> </dl> <p> This command returns information about the stream stored at <code> &lt;key&gt; </code> . </p> <p> The informative details provided by this command are: </p> <ul> <li> <strong> length </strong> : the number of entries in the stream (see <a href="/docs/latest/commands/xlen/"> <code> XLEN </code> </a> ) </li> <li> <strong> radix-tree-keys </strong> : the number of keys in the underlying radix data structure </li> <li> <strong> radix-tree-nodes </strong> : the number of nodes in the underlying radix data structure </li> <li> <strong> groups </strong> : the number of consumer groups defined for the stream </li> <li> <strong> last-generated-id </strong> : the ID of the least-recently entry that was added to the stream </li> <li> <strong> max-deleted-entry-id </strong> : the maximal entry ID that was deleted from the stream </li> <li> <strong> entries-added </strong> : the count of all entries added to the stream during its lifetime </li> <li> <strong> first-entry </strong> : the ID and field-value tuples of the first entry in the stream </li> <li> <strong> last-entry </strong> : the ID and field-value tuples of the last entry in the stream </li> </ul> <h3 id="the-full-modifier"> The <code> FULL </code> modifier </h3> <p> The optional <code> FULL </code> modifier provides a more verbose reply. When provided, the <code> FULL </code> reply includes an <strong> entries </strong> array that consists of the stream entries (ID and field-value tuples) in ascending order. Furthermore, <strong> groups </strong> is also an array, and for each of the consumer groups it consists of the information reported by <a href="/docs/latest/commands/xinfo-groups/"> <code> XINFO GROUPS </code> </a> and <a href="/docs/latest/commands/xinfo-consumers/"> <code> XINFO CONSUMERS </code> </a> . </p> <p> The following information is provided for each of the groups: </p> <ul> <li> <strong> name </strong> : the consumer group's name </li> <li> <strong> last-delivered-id </strong> : the ID of the last entry delivered to the group's consumers </li> <li> <strong> entries-read </strong> : the logical "read counter" of the last entry delivered to the group's consumers </li> <li> <strong> lag </strong> : the number of entries in the stream that are still waiting to be delivered to the group's consumers, or a NULL when that number can't be determined. </li> <li> <strong> pel-count </strong> : the length of the group's pending entries list (PEL), which are messages that were delivered but are yet to be acknowledged </li> <li> <strong> pending </strong> : an array with pending entries information (see below) </li> <li> <strong> consumers </strong> : an array with consumers information (see below) </li> </ul> <p> The following information is provided for each pending entry: </p> <ol> <li> The ID of the message. </li> <li> The name of the consumer that fetched the message and has still to acknowledge it. We call it the current <em> owner </em> of the message. </li> <li> The UNIX timestamp of when the message was delivered to this consumer. </li> <li> The number of times this message was delivered. </li> </ol> <p> The following information is provided for each consumer: </p> <ul> <li> <strong> name </strong> : the consumer's name </li> <li> <strong> seen-time </strong> : the UNIX timestamp of the last attempted interaction (Examples: <a href="/docs/latest/commands/xreadgroup/"> <code> XREADGROUP </code> </a> , <a href="/docs/latest/commands/xclaim/"> <code> XCLAIM </code> </a> , <a href="/docs/latest/commands/xautoclaim/"> <code> XAUTOCLAIM </code> </a> ) </li> <li> <strong> active-time </strong> : the UNIX timestamp of the last successful interaction (Examples: <a href="/docs/latest/commands/xreadgroup/"> <code> XREADGROUP </code> </a> that actually read some entries into the PEL, <a href="/docs/latest/commands/xclaim/"> <code> XCLAIM </code> </a> / <a href="/docs/latest/commands/xautoclaim/"> <code> XAUTOCLAIM </code> </a> that actually claimed some entries) </li> <li> <strong> pel-count </strong> : the number of entries in the PEL: pending messages for the consumer, which are messages that were delivered but are yet to be acknowledged </li> <li> <strong> pending </strong> : an array with pending entries information, has the same structure as described above, except the consumer name is omitted (redundant, since anyway we are in a specific consumer context) </li> </ul> <p> Note that before Redis 7.2.0, <strong> seen-time </strong> used to denote the last successful interaction. In 7.2.0, <strong> active-time </strong> was added and <strong> seen-time </strong> was changed to denote the last attempted interaction. </p> <p> The <code> COUNT </code> option can be used to limit the number of stream and PEL entries that are returned (The first <code> &lt;count&gt; </code> entries are returned). The default <code> COUNT </code> is 10 and a <code> COUNT </code> of 0 means that all entries will be returned (execution time may be long if the stream has a lot of entries). </p> <h2 id="examples"> Examples </h2> <p> Default reply: </p> <pre tabindex="0"><code>&gt; XINFO STREAM mystream 1) "length" 2) (integer) 2 3) "radix-tree-keys" 4) (integer) 1 5) "radix-tree-nodes" 6) (integer) 2 7) "last-generated-id" 8) "1638125141232-0" 9) "max-deleted-entry-id" 10) "0-0" 11) "entries-added" 12) (integer) 2 13) "recorded-first-entry-id" 14) "1719505260513-0" 15) "groups" 16) (integer) 1 17) "first-entry" 18) 1) "1638125133432-0" 2) 1) "message" 2) "apple" 19) "last-entry" 20) 1) "1638125141232-0" 2) 1) "message" 2) "banana" </code></pre> <p> Full reply: </p> <pre tabindex="0"><code>&gt; XADD mystream * foo bar "1638125133432-0" &gt; XADD mystream * foo bar2 "1638125141232-0" &gt; XGROUP CREATE mystream mygroup 0-0 OK &gt; XREADGROUP GROUP mygroup Alice COUNT 1 STREAMS mystream &gt; 1) 1) "mystream" 2) 1) 1) "1638125133432-0" 2) 1) "foo" 2) "bar" &gt; XINFO STREAM mystream FULL 1) "length" 2) (integer) 2 3) "radix-tree-keys" 4) (integer) 1 5) "radix-tree-nodes" 6) (integer) 2 7) "last-generated-id" 8) "1638125141232-0" 9) "max-deleted-entry-id" 10) "0-0" 11) "entries-added" 12) (integer) 2 13) "recorded-first-entry-id" 14) "1719505260513-0" 15) "entries" 16) 1) 1) "1638125133432-0" 2) 1) "foo" 2) "bar" 2) 1) "1638125141232-0" 2) 1) "foo" 2) "bar2" 17) "groups" 18) 1) 1) "name" 2) "mygroup" 3) "last-delivered-id" 4) "1638125133432-0" 5) "entries-read" 6) (integer) 1 7) "lag" 8) (integer) 1 9) "pel-count" 10) (integer) 1 11) "pending" 12) 1) 1) "1638125133432-0" 2) "Alice" 3) (integer) 1638125153423 4) (integer) 1 13) "consumers" 14) 1) 1) "name" 2) "Alice" 3) "seen-time" 4) (integer) 1638125133422 5) "active-time" 6) (integer) 1638125133432 7) "pel-count" 8) (integer) 1 9) "pending" 10) 1) 1) "1638125133432-0" 2) (integer) 1638125133432 3) (integer) 1 </code></pre> <h2 id="resp2-reply"> RESP2 Reply </h2> <p> One of the following: </p> <ul> <li> <a href="../../develop/reference/protocol-spec#arrays"> Array reply </a> : when the <em> FULL </em> argument is used, a list of information about a stream in summary form. </li> <li> <a href="../../develop/reference/protocol-spec#arrays"> Array reply </a> : when the <em> FULL </em> argument is used, a list of information about a stream in extended form. </li> </ul> <h2 id="resp3-reply"> RESP3 Reply </h2> <p> One of the following: </p> <ul> <li> <a href="../../develop/reference/protocol-spec#maps"> Map reply </a> : when the <em> FULL </em> argument was not given, a list of information about a stream in summary form. </li> <li> <a href="../../develop/reference/protocol-spec#maps"> Map reply </a> : when the <em> FULL </em> argument was given, a list of information about a stream in extended form. </li> </ul> <br/> <h2> History </h2> <ul> <li> Starting with Redis version 6.0.0: Added the <code> FULL </code> modifier. </li> <li> Starting with Redis version 7.0.0: Added the <code> max-deleted-entry-id </code> , <code> entries-added </code> , <code> recorded-first-entry-id </code> , <code> entries-read </code> and <code> lag </code> fields </li> <li> Starting with Redis version 7.2.0: Added the <code> active-time </code> field, and changed the meaning of <code> seen-time </code> . </li> </ul> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/xinfo-stream/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/integrate/prometheus-with-redis-cloud/.html
<section class="prose w-full py-12 max-w-none"> <h1> Prometheus and Grafana with Redis Cloud </h1> <p class="text-lg -mt-5 mb-10"> Use Prometheus and Grafana to collect and visualize Redis Cloud metrics. </p> <p> You can use Prometheus and Grafana to collect and visualize your Redis Cloud metrics. </p> <ul> <li> <a href="https://prometheus.io/"> Prometheus </a> is an open source systems monitoring and alerting toolkit that can scrape metrics from different sources. </li> <li> <a href="https://grafana.com/"> Grafana </a> is an open source metrics visualization tool that can process Prometheus data. </li> </ul> <p> Redis Cloud exposes its metrics through a Prometheus endpoint. You can configure your Prometheus server to scrape metrics from your Redis Cloud subscription on port 8070. </p> <p> The Redis Cloud Prometheus endpoint is exposed on Redis Cloud's internal network. To access this network, enable <a href="/docs/latest/operate/rc/security/vpc-peering/"> VPC peering </a> or <a href="/docs/latest/operate/rc/security/private-service-connect/"> Private Service Connect </a> . Both options are only available with Redis Cloud Pro. You cannot use Prometheus and Grafana with Redis Cloud Essentials. </p> <p> For more information on how Prometheus communicates with Redis Enterprise clusters, see <a href="/docs/latest/integrate/prometheus-with-redis-enterprise/"> Prometheus integration with Redis Enterprise Software </a> . </p> <h2 id="quick-start"> Quick start </h2> <p> You can quickly set up Prometheus and Grafana for testing using the Prometheus and Grafana Docker images. </p> <h3 id="prerequisites"> Prerequisites </h3> <ol> <li> <p> Create a <a href="/docs/latest/operate/rc/databases/create-database/create-pro-database-new/"> Redis Cloud Pro database </a> . </p> </li> <li> <p> Set up <a href="/docs/latest/operate/rc/security/vpc-peering/"> VPC peering </a> . </p> </li> <li> <p> Extract the Prometheus endpoint from the private endpoint to your database. The private endpoint is in the <a href="https://cloud.redis.io/"> Redis Cloud console </a> under the <a href="/docs/latest/operate/rc/databases/view-edit-database/#configuration-tab"> Configuration tab </a> of your database. The Prometheus endpoint is on port 8070 of the internal server. </p> <p> For example, if your private endpoint is: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">redis-12345.internal.&lt;cluster_address&gt;:12345 </span></span></code></pre> </div> <p> The Prometheus endpoint is: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">internal.&lt;cluster_address&gt;:8070 </span></span></code></pre> </div> </li> <li> <p> Create an instance to run Prometheus and Grafana on the same cloud provider as your Redis Cloud subscription (for example, Amazon Web Services or Google Cloud). This instance must: </p> <ul> <li> Exist in the same region as your Redis Cloud subscription. </li> <li> Connect to the VPC subnet that is peered with your Redis Cloud subscription. </li> <li> Allow outbound connections to port 8070, so that Prometheus can scrape the Redis Cloud server for data. </li> <li> Allow inbound connections to port 9090 for Prometheus and port 3000 for Grafana. </li> </ul> </li> </ol> <h3 id="set-up-prometheus"> Set up Prometheus </h3> <p> To get started with custom monitoring with Prometheus on Docker: </p> <ol> <li> <p> Create a directory on the Prometheus instance called <code> prometheus </code> and create a <code> prometheus.yml </code> file in that directory. </p> </li> <li> <p> Add the following contents to <code> prometheus.yml </code> . Replace <code> &lt;prometheus_endpoint&gt; </code> with the Prometheus endpoint. </p> <div class="highlight"> <pre class="chroma"><code class="language-yml" data-lang="yml"><span class="line"><span class="cl"><span class="nt">global</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">scrape_interval</span><span class="p">:</span><span class="w"> </span><span class="l">15s</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">evaluation_interval</span><span class="p">:</span><span class="w"> </span><span class="l">15s</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="c"># Attach these labels to any time series or alerts when communicating with</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="c"># external systems (federation, remote storage, Alertmanager).</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">external_labels</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">monitor</span><span class="p">:</span><span class="w"> </span><span class="s2">"prometheus-stack-monitor"</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="c"># Load and evaluate rules in this file every 'evaluation_interval' seconds.</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="c">#rule_files:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="c"># - "first.rules"</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="c"># - "second.rules"</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">scrape_configs</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="c"># scrape Prometheus itself</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">job_name</span><span class="p">:</span><span class="w"> </span><span class="l">prometheus</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">scrape_interval</span><span class="p">:</span><span class="w"> </span><span class="l">10s</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">scrape_timeout</span><span class="p">:</span><span class="w"> </span><span class="l">5s</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">static_configs</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">targets</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"localhost:9090"</span><span class="p">]</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="c"># scrape Redis Cloud</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">job_name</span><span class="p">:</span><span class="w"> </span><span class="l">redis-cloud</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">scrape_interval</span><span class="p">:</span><span class="w"> </span><span class="l">30s</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">scrape_timeout</span><span class="p">:</span><span class="w"> </span><span class="l">30s</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">metrics_path</span><span class="p">:</span><span class="w"> </span><span class="l">/</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">scheme</span><span class="p">:</span><span class="w"> </span><span class="l">https</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">static_configs</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">targets</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"&lt;prometheus_endpoint&gt;:8070"</span><span class="p">]</span><span class="w"> </span></span></span></code></pre> </div> </li> <li> <p> Create a <code> docker-compose.yml </code> file with instructions to set up the Prometheus and Grafana Docker images. </p> <div class="highlight"> <pre class="chroma"><code class="language-yml" data-lang="yml"><span class="line"><span class="cl"><span class="nt">version</span><span class="p">:</span><span class="w"> </span><span class="s1">'3'</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">services</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">prometheus-server</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">image</span><span class="p">:</span><span class="w"> </span><span class="l">prom/prometheus</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">ports</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="m">9090</span><span class="p">:</span><span class="m">9090</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">volumes</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="l">./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">grafana-ui</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">image</span><span class="p">:</span><span class="w"> </span><span class="l">grafana/grafana</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">ports</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="m">3000</span><span class="p">:</span><span class="m">3000</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">environment</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="l">GF_SECURITY_ADMIN_PASSWORD=secret</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">links</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="l">prometheus-server:prometheus</span><span class="w"> </span></span></span></code></pre> </div> </li> <li> <p> To start the containers, run: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ docker compose up -d </span></span></code></pre> </div> </li> <li> <p> To check that all the containers are up, run: <code> docker ps </code> </p> </li> <li> <p> In your browser, sign in to Prometheus at <code> http://localhost:9090 </code> to make sure the server is running. </p> </li> <li> <p> Select <strong> Status </strong> and then <strong> Targets </strong> to check that Prometheus is collecting data from the Redis Cloud cluster. </p> <a href="/docs/latest/images/rs/prometheus-target.png" sdata-lightbox="/images/rs/prometheus-target.png"> <img alt="The Redis Enterprise target showing that Prometheus is connected to the Redis Enterprise Cluster." src="/docs/latest/images/rs/prometheus-target.png"/> </a> <p> If Prometheus is connected to the cluster, you can type <strong> node_up </strong> in the Expression field on the Prometheus home page to see the cluster metrics. </p> </li> </ol> <p> See <a href="/docs/latest/integrate/prometheus-with-redis-enterprise/prometheus-metrics-definitions/"> Prometheus Metrics </a> for a list of metrics that Prometheus collects from Redis Enterprise clusters. </p> <h3 id="set-up-grafana"> Set up Grafana </h3> <p> Once the Prometheus and Grafana Docker containers are running, and Prometheus is connected to your Redis Cloud subscription, you can set up your Grafana dashboards. </p> <ol> <li> <p> Sign in to Grafana. If you installed Grafana with Docker, go to <code> http://localhost:3000 </code> and sign in with: </p> <ul> <li> Username: <code> admin </code> </li> <li> Password: <code> secret </code> </li> </ul> </li> <li> <p> In the Grafana configuration menu, select <strong> Data Sources </strong> . </p> </li> <li> <p> Select <strong> Add data source </strong> . </p> </li> <li> <p> Select <strong> Prometheus </strong> from the list of data source types. </p> <a href="/docs/latest/images/rs/prometheus-datasource.png" sdata-lightbox="/images/rs/prometheus-datasource.png"> <img alt="The Prometheus data source in the list of data sources on Grafana." src="/docs/latest/images/rs/prometheus-datasource.png"/> </a> </li> <li> <p> Enter the Prometheus configuration information: </p> <ul> <li> Name: <code> redis-cloud </code> </li> <li> URL: <code> http://prometheus-server:9090 </code> </li> <li> Access: <code> Server </code> </li> </ul> <a href="/docs/latest/images/rc/prometheus-connection.png" sdata-lightbox="/images/rc/prometheus-connection.png"> <img alt="The Prometheus connection form in Grafana." src="/docs/latest/images/rc/prometheus-connection.png"/> </a> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> <ul> <li> If the network port is not accessible to the Grafana server, select the <strong> Browser </strong> option from the Access menu. </li> <li> In a testing environment, you can select <strong> Skip TLS verification </strong> . </li> </ul> </div> </div> </li> <li> <p> Add dashboards for your subscription and database metrics. To add preconfigured dashboards: </p> <ol> <li> In the Grafana dashboards menu, select <strong> Manage </strong> . </li> <li> Select <strong> Import </strong> . </li> <li> Add the <a href="https://grafana.com/grafana/dashboards/18406-subscription-status-dashboard/"> subscription status </a> and <a href="https://grafana.com/grafana/dashboards/18407-database-status-dashboard/"> database status </a> dashboards. </li> </ol> </li> </ol> <h3 id="grafana-dashboards-for-redis-cloud"> Grafana dashboards for Redis Cloud </h3> <p> Redis publishes preconfigured dashboards for Redis Cloud and Grafana: </p> <ul> <li> The <a href="https://grafana.com/grafana/dashboards/18406-subscription-status-dashboard/"> subscription status dashboard </a> provides an overview of your Redis Cloud subscriptions. </li> <li> The <a href="https://grafana.com/grafana/dashboards/18407-database-status-dashboard/"> database status dashboard </a> displays specific database metrics, including latency, memory usage, ops/second, and key count. </li> <li> The <a href="https://github.com/redis-field-engineering/redis-enterprise-observability/blob/main/grafana/dashboards/grafana_v9-11/cloud/basic/redis-cloud-active-active-dashboard_v9-11.json"> Active-Active dashboard </a> displays metrics specific to <a href="/docs/latest/operate/rc/databases/configuration/active-active-redis/"> Active-Active databases </a> . </li> </ul> <p> These dashboards are open source. For additional dashboard options, or to file an issue, see the <a href="https://github.com/redis-field-engineering/redis-enterprise-observability/tree/main/grafana"> Redis Enterprise observability Github repository </a> . </p> <p> For more information about configuring Grafana dashboards, see the <a href="https://grafana.com/docs/"> Grafana documentation </a> . </p> <nav> </nav> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/integrate/prometheus-with-redis-cloud/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/7.4/release-notes/legacy-release-notes/.html
<section class="prose w-full py-12 max-w-none"> <h1> Previous releases </h1> <p class="text-lg -mt-5 mb-10"> Release notes for Redis Enterprise Software 5.6.0 (April 2020) and earlier versions. </p> <table> <thead> <tr> <th style="text-align:left"> Version (Release date) </th> <th style="text-align:left"> Major changes </th> <th style="text-align:left"> OSS Redis compatibility </th> </tr> </thead> <tbody> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/release-notes/legacy-release-notes/rs-5-6-0-april-2020/"> 5.6.0 (April 2020) </a> </td> <td style="text-align:left"> Install improvements for RHEL 6 and 7. Active-Active support for HyperLogLog. Auto Tiering now supports RedisJSON. Active-Active default changes for high availability and OSS Cluster API support. Backup support for Google Cloud Storage and Azure Blob storage. </td> <td style="text-align:left"> Redis 5.0.8 </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/release-notes/legacy-release-notes/rs-5-5-preview-april-2019/"> 5.5 preview (April 2019) </a> </td> <td style="text-align:left"> Preview release. Databases support multiple modules. </td> <td style="text-align:left"> </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/release-notes/legacy-release-notes/rs-5-4-14-february-2020/"> 5.4.14 (February 2020) </a> </td> <td style="text-align:left"> </td> <td style="text-align:left"> </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/release-notes/legacy-release-notes/rs-5-4-10-december-2019/"> 5.4.10 (December 2019) </a> </td> <td style="text-align:left"> </td> <td style="text-align:left"> </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/release-notes/legacy-release-notes/rs-5-4-6-july-2019/"> 5.4.6 (July 2019) </a> </td> <td style="text-align:left"> </td> <td style="text-align:left"> </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/release-notes/legacy-release-notes/rs-5-4-4-june-2019/"> 5.4.4 (June 2019) </a> </td> <td style="text-align:left"> </td> <td style="text-align:left"> </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/release-notes/legacy-release-notes/rs-5-4-2-april-2019/"> 5.4.2 (April 2019) </a> </td> <td style="text-align:left"> </td> <td style="text-align:left"> </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/release-notes/legacy-release-notes/rs-5-4-december-2018/"> 5.4 (December 2018) </a> </td> <td style="text-align:left"> </td> <td style="text-align:left"> </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/release-notes/legacy-release-notes/rs-5-2-2-august-2018/"> 5.2.2 (August 2018) </a> </td> <td style="text-align:left"> </td> <td style="text-align:left"> </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/release-notes/legacy-release-notes/rs-5-3-beta-july-2018/"> 5.3 beta(July 2018) </a> </td> <td style="text-align:left"> </td> <td style="text-align:left"> </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/release-notes/legacy-release-notes/rs-5-2-june-2018/"> 5.2 (June 2018) </a> </td> <td style="text-align:left"> </td> <td style="text-align:left"> </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/release-notes/legacy-release-notes/release-notes-redis-enterprise-software-v5-0-2/"> 5.0.2 (2018 March) </a> </td> <td style="text-align:left"> </td> <td style="text-align:left"> </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/release-notes/legacy-release-notes/redis-enterprise-5/"> 5.0 (November 2017) </a> </td> <td style="text-align:left"> </td> <td style="text-align:left"> </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/release-notes/legacy-release-notes/redis-pack-4-5-0-may-2017/"> 4.5 (May 2017) </a> </td> <td style="text-align:left"> </td> <td style="text-align:left"> </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/release-notes/legacy-release-notes/rlec-4-4-dec-2016/"> 4.4 (December 2016) </a> </td> <td style="text-align:left"> </td> <td style="text-align:left"> </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/release-notes/legacy-release-notes/rlec-4-3-aug-2016/"> 4.3.0-230 (August 2, 2016) </a> </td> <td style="text-align:left"> </td> <td style="text-align:left"> </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/release-notes/legacy-release-notes/rlec-4-2-october-2015/"> 4.2.1-30 (October 18, 2015) </a> </td> <td style="text-align:left"> </td> <td style="text-align:left"> </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/release-notes/legacy-release-notes/rlec-4-0-june-2015/"> 4.0.0-49 (June 18, 2015) </a> </td> <td style="text-align:left"> </td> <td style="text-align:left"> </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/release-notes/legacy-release-notes/rlec-0-99-february-2015/"> 0.99.5-24 (February 15, 2015) </a> </td> <td style="text-align:left"> </td> <td style="text-align:left"> </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/release-notes/legacy-release-notes/rlec-0-99-5-11-january-2015/"> 0.99.5-11 (January 5, 2015) </a> </td> <td style="text-align:left"> </td> <td style="text-align:left"> </td> </tr> </tbody> </table> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/release-notes/legacy-release-notes/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rc/security/cidr-whitelist/.html
<section class="prose w-full py-12 max-w-none"> <h1> Configure CIDR allow list </h1> <p class="text-lg -mt-5 mb-10"> The CIDR allow list permits traffic between a range of IP addresses and the Redis Cloud VPC. </p> <p> The <a href="https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing"> CIDR </a> <a href="https://en.wikipedia.org/wiki/Whitelist"> allow list </a> lets you restrict traffic to your Redis Cloud database. When you configure an allow list, only the <a href="https://en.wikipedia.org/wiki/IP_address"> IP addresses </a> defined in the list can connect to the database. Traffic from all other IP addresses is blocked. </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> To use the CIDR allow list, you must be on either paid Redis Cloud Essentials or on Redis Cloud Pro. This feature is not supported on free Redis Cloud Essentials plans. </div> </div> <h2 id="define-cidr-allow-list"> Define CIDR allow list </h2> <p> To define the CIDR allow list for a database: </p> <ol> <li> <p> Select <strong> Databases </strong> from the <a href="https://cloud.redis.io/"> Redis Cloud console </a> menu and then select your database from the list. </p> </li> <li> <p> From the database's <strong> Configuration </strong> screen, select the <strong> Edit database </strong> button. </p> </li> <li> <p> In the <strong> Security </strong> section, turn on the <strong> CIDR allow list </strong> toggle. </p> </li> <li> <p> Enter the first IP address (in CIDR format) you want to allow in the text box and then select the check mark to add it to the allow list: </p> <a href="/docs/latest/images/rc/database-details-configuration-tab-security-cidr-allowlist-add-first-ip.png" sdata-lightbox="/images/rc/database-details-configuration-tab-security-cidr-allowlist-add-first-ip.png"> <img alt="Add the first IP address to the CIDR allow list." src="/docs/latest/images/rc/database-details-configuration-tab-security-cidr-allowlist-add-first-ip.png" width="300px"/> </a> </li> <li> <p> To allow additional IP addresses: </p> <ol> <li> <p> Select <strong> Add CIDR </strong> . </p> </li> <li> <p> Enter the new IP address in the text box and then select check to add it to the allow list. </p> <a href="/docs/latest/images/rc/database-details-configuration-tab-security-cidr-allowlist-add-more-ips.png" sdata-lightbox="/images/rc/database-details-configuration-tab-security-cidr-allowlist-add-more-ips.png"> <img alt="Add a new IP address to the CIDR allow list." src="/docs/latest/images/rc/database-details-configuration-tab-security-cidr-allowlist-add-more-ips.png" width="300px"/> </a> </li> </ol> </li> <li> <p> Select <strong> Save database </strong> to apply your changes. </p> </li> </ol> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> The database CIDR allow list applies to both the public endpoint and the private endpoint. If you use connectivity options such as <a href="/docs/latest/operate/rc/security/vpc-peering/"> VPC Peering </a> and <a href="/docs/latest/operate/rc/security/aws-transit-gateway/"> Transit Gateway </a> to connect to your database via the private endpoint, you must also add those IPs to your database's CIDR allow list. </div> </div> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rc/security/cidr-whitelist/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rc/security/encryption-at-rest/.html
<section class="prose w-full py-12 max-w-none"> <h1> Encryption at rest </h1> <p class="text-lg -mt-5 mb-10"> Describes when data is encrypted at rest. </p> <p> Redis Cloud databases write their data to disk whenever <a href="/docs/latest/operate/rc/databases/configuration/data-persistence/"> persistence </a> is enabled. </p> <p> Redis Cloud deployments are always encrypted at rest. </p> <h2 id="aws"> Encryption at rest on AWS </h2> <p> Persistent data is written to encrypted EBS volumes. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSEncryption.html"> Amazon EBS encryption </a> . </p> <p> When Auto Tiering is enabled, the flash memory data is written to encrypted NVMe SSD volumes. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ssd-instance-store.html"> SSD instance store volumes </a> . </p> <h2 id="gcp"> Disk encryption on Google Cloud </h2> <p> All data written to disk on Google Cloud-based Redis Cloud deployments is encrypted by default. When deploying a Redis Cloud database on Google Cloud, you don't need to take any actions to enable this encryption. </p> <p> To learn more, see the <a href="https://cloud.google.com/security/encryption-at-rest"> Google Cloud Default encryption at rest </a> . </p> <h2 id="azure"> Disk encryption on Azure </h2> <p> All data written to disk on Azure-based Redis Cloud deployments is encrypted by default. When deploying a Redis Cloud database on Azure, you don't need to take any actions to enable this encryption. </p> <p> To learn more, see the <a href="https://docs.microsoft.com/en-us/azure/security/fundamentals/encryption-atrest"> Azure Data Encryption at rest </a> . </p> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rc/security/encryption-at-rest/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/client-trackinginfo/.html
<section class="prose w-full py-12"> <h1 class="command-name"> CLIENT TRACKINGINFO </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">CLIENT TRACKINGINFO</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available since: </dt> <dd class="m-0"> 6.2.0 </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(1) </dd> <dt class="font-semibold text-redis-ink-900 m-0"> ACL categories: </dt> <dd class="m-0"> <code> @slow </code> <span class="mr-1 last:hidden"> , </span> <code> @connection </code> <span class="mr-1 last:hidden"> , </span> </dd> </dl> <p> The command returns information about the current client connection's use of the <a href="/docs/latest/develop/clients/client-side-caching/"> server assisted client side caching </a> feature. </p> <p> Here's the list of tracking information sections and their respective values: </p> <ul> <li> <strong> flags </strong> : A list of tracking flags used by the connection. The flags and their meanings are as follows: <ul> <li> <code> off </code> : The connection isn't using server assisted client side caching. </li> <li> <code> on </code> : Server assisted client side caching is enabled for the connection. </li> <li> <code> bcast </code> : The client uses broadcasting mode. </li> <li> <code> optin </code> : The client does not cache keys by default. </li> <li> <code> optout </code> : The client caches keys by default. </li> <li> <code> caching-yes </code> : The next command will cache keys (exists only together with <code> optin </code> ). </li> <li> <code> caching-no </code> : The next command won't cache keys (exists only together with <code> optout </code> ). </li> <li> <code> noloop </code> : The client isn't notified about keys modified by itself. </li> <li> <code> broken_redirect </code> : The client ID used for redirection isn't valid anymore. </li> </ul> </li> <li> <strong> redirect </strong> : The client ID used for notifications redirection, 0 for self-redirection, or -1 when none. </li> <li> <strong> prefixes </strong> : A list of key prefixes for which notifications are sent to the client. </li> </ul> <h2 id="resp2-reply"> RESP2 Reply </h2> <a href="../../develop/reference/protocol-spec#arrays"> Array reply </a> : a list of tracking information sections and their respective values. <h2 id="resp3-reply"> RESP3 Reply </h2> <a href="../../develop/reference/protocol-spec#maps"> Map reply </a> : a list of tracking information sections and their respective values. <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/client-trackinginfo/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/install/.html
<section class="prose w-full py-12 max-w-none"> <h1> Install and upgrade modules </h1> <p> Several modules, which provide Redis Stack features, come packaged with <a href="/docs/latest/operate/rs/"> Redis Enterprise Software </a> . As of version 7.8.2, Redis Enterprise Software includes three feature sets, compatible with different Redis database versions. However, if you want to use additional modules or upgrade a module to a more recent version, you need to: </p> <ol> <li> <a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/install/add-module-to-cluster/"> Install a module package </a> on the cluster. </li> <li> <a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/install/add-module-to-database/"> Enable a module </a> for a new database or <a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/install/upgrade-module/"> upgrade a module </a> in an existing database. </li> </ol> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/install/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/redisjson/redisjson-2.8-release-notes/.html
<section class="prose w-full py-12 max-w-none"> <h1> RedisJSON 2.8 release notes </h1> <p class="text-lg -mt-5 mb-10"> RedisJSON 2.8 introduces bug fixes. </p> <h2 id="requirements"> Requirements </h2> <p> RedisJSON v2.8.4 requires: </p> <ul> <li> Minimum Redis compatibility version (database): 7.4 </li> <li> Minimum Redis Enterprise Software version (cluster): 7.6 (TBD) </li> </ul> <h2 id="v284-september-2024"> v2.8.4 (September 2024) </h2> <p> This is a maintenance release for RedisJSON 2.8 </p> <p> Update urgency: <code> MODERATE </code> : Program an upgrade of the server, but it's not urgent. </p> <p> Details: </p> <ul> <li> <p> Bug fixes: </p> <ul> <li> <a href="https://github.com/redisjson/redisjson/pull/1225"> #1225 </a> Crash on SET commands with recursive overlapping paths (MOD-7279) </li> <li> HDT#261 (Redis Enterprise A-A only) Crash when a JSON contains an EOF character (MOD-7464) </li> </ul> </li> </ul> <h2 id="v28-ga-v283-july-2024"> v2.8 GA (v2.8.3) (July 2024) </h2> <p> This is the General Availability release of RedisJSON 2.8 </p> <h3 id="headlines"> Headlines: </h3> <p> RedisJSON 2.8 introduces bug fixes. </p> <p> Details </p> <ul> <li> <p> Bug fixes </p> <ul> <li> <a href="https://github.com/RedisJSON/RedisJSON/pull/1212"> #1212 </a> <code> JSON.MSET </code> - AOF commands are duplicated multiple times (MOD-7293) </li> </ul> </li> </ul> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> <ul> <li> The version inside Redis will be 2.8.3 in semantic versioning. Since the version of a module in Redis is numeric, we could not add a GA flag. </li> <li> Minimal Redis version: 7.4 </li> </ul> </div> </div> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/redisjson/redisjson-2.8-release-notes/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/grouptdigest.html
<section class="prose w-full py-12"> <h1> Commands </h1> </section>
https://redis.io/docs/latest/develop/data-types/lists/.html
<section class="prose w-full py-12"> <h1> Redis lists </h1> <p class="text-lg -mt-5 mb-10"> Introduction to Redis lists </p> <p> Redis lists are linked lists of string values. Redis lists are frequently used to: </p> <ul> <li> Implement stacks and queues. </li> <li> Build queue management for background worker systems. </li> </ul> <h2 id="basic-commands"> Basic commands </h2> <ul> <li> <a href="/docs/latest/commands/lpush/"> <code> LPUSH </code> </a> adds a new element to the head of a list; <a href="/docs/latest/commands/rpush/"> <code> RPUSH </code> </a> adds to the tail. </li> <li> <a href="/docs/latest/commands/lpop/"> <code> LPOP </code> </a> removes and returns an element from the head of a list; <a href="/docs/latest/commands/rpop/"> <code> RPOP </code> </a> does the same but from the tails of a list. </li> <li> <a href="/docs/latest/commands/llen/"> <code> LLEN </code> </a> returns the length of a list. </li> <li> <a href="/docs/latest/commands/lmove/"> <code> LMOVE </code> </a> atomically moves elements from one list to another. </li> <li> <a href="/docs/latest/commands/lrange/"> <code> LRANGE </code> </a> extracts a range of elements from a list. </li> <li> <a href="/docs/latest/commands/ltrim/"> <code> LTRIM </code> </a> reduces a list to the specified range of elements. </li> </ul> <h3 id="blocking-commands"> Blocking commands </h3> <p> Lists support several blocking commands. For example: </p> <ul> <li> <a href="/docs/latest/commands/blpop/"> <code> BLPOP </code> </a> removes and returns an element from the head of a list. If the list is empty, the command blocks until an element becomes available or until the specified timeout is reached. </li> <li> <a href="/docs/latest/commands/blmove/"> <code> BLMOVE </code> </a> atomically moves elements from a source list to a target list. If the source list is empty, the command will block until a new element becomes available. </li> </ul> <p> See the <a href="/docs/latest/commands/?group=list"> complete series of list commands </a> . </p> <h2 id="examples"> Examples </h2> <ul> <li> <p> Treat a list like a queue (first in, first out): </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="list_tutorial-stepqueue"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_list_tutorial-stepqueue" name="list_tutorial-stepqueue" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_list_tutorial-stepqueue" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-list_tutorial-stepqueue" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_list_tutorial-stepqueue" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; LPUSH bikes:repairs bike:1 </span></span><span class="line hl"><span class="cl">(integer) 1 </span></span><span class="line hl"><span class="cl">&gt; LPUSH bikes:repairs bike:2 </span></span><span class="line hl"><span class="cl">(integer) 2 </span></span><span class="line hl"><span class="cl">&gt; RPOP bikes:repairs </span></span><span class="line hl"><span class="cl">"bike:1" </span></span><span class="line hl"><span class="cl">&gt; RPOP bikes:repairs </span></span><span class="line hl"><span class="cl">"bike:2"</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_list_tutorial-stepqueue')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_list_tutorial-stepqueue" name="list_tutorial-stepqueue" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_list_tutorial-stepqueue" title="Open example"> Python </label> <div aria-labelledby="tab-list_tutorial-stepqueue" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_list_tutorial-stepqueue" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for List doc pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/lists/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:1</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">llen</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lmove</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bikes:finished"</span><span class="p">,</span> <span class="s2">"LEFT"</span><span class="p">,</span> <span class="s2">"LEFT"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:1']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:finished"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:2']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:important_bike"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res18</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:important_bike', 'bike:1', 'bike:2']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:important_bike"</span><span class="p">,</span> <span class="s2">"bike:very_important_bike"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="n">res21</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:very_important_bike', 'bike:important_bike', 'bike:1', ...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res22</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res22</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res23</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res23</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:3'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res24</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res24</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:1'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res25</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res25</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res26</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res26</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res28</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res28</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res29</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res29</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:5', 'bike:4', 'bike:3']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res28</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res28</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res29</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res29</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:3', 'bike:4', 'bike:5']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res31</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res31</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res32</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res32</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ('bikes:repairs', 'bike:2')</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res33</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res33</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ('bikes:repairs', 'bike:1')</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res34</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res34</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res35</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res35</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res36</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res36</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res37</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res37</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res38</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">type</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res38</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'string'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">try</span><span class="p">:</span> </span></span><span class="line"><span class="cl"> <span class="n">res39</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1"># &gt;&gt;&gt; redis.exceptions.ResponseError:</span> </span></span><span class="line"><span class="cl"> <span class="c1"># &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value</span> </span></span><span class="line"><span class="cl"><span class="k">except</span> <span class="n">redis</span><span class="o">.</span><span class="n">exceptions</span><span class="o">.</span><span class="n">ResponseError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> </span></span><span class="line"><span class="cl"> <span class="nb">print</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res36</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res40</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res40</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res41</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res41</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:3'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res42</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res42</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res43</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res43</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:1'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res44</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res44</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res45</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res45</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res46</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">llen</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res46</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res47</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res47</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res48</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res48</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res49</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res49</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res50</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res50</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:5', 'bike:4', 'bike:3']</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_list_tutorial-stepqueue')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_list_tutorial-stepqueue" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_list.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_list_tutorial-stepqueue" name="list_tutorial-stepqueue" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_list_tutorial-stepqueue" title="Open example"> Node.js </label> <div aria-labelledby="tab-list_tutorial-stepqueue" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_list_tutorial-stepqueue" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">createClient</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">);</span> <span class="c1">// bike:1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">);</span> <span class="c1">// bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">);</span> <span class="c1">// bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">);</span> <span class="c1">// bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lLen</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lMove</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bikes:finished'</span><span class="p">,</span> <span class="s1">'LEFT'</span><span class="p">,</span> <span class="s1">'LEFT'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res13</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res13</span><span class="p">);</span> <span class="c1">// ['bike:1'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:finished'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res14</span><span class="p">);</span> <span class="c1">// ['bike:2'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res15</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res15</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res16</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res16</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res17</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:important_bike'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res17</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res18</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res18</span><span class="p">);</span> <span class="c1">// ['bike:important_bike', 'bike:1', 'bike:2'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res19</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:important_bike'</span><span class="p">,</span> <span class="s1">'bike:very_important_bike'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res20</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res21</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res21</span><span class="p">);</span> <span class="c1">// ['bike:very_important_bike', 'bike:important_bike', 'bike:1', 'bike:2', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res22</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res22</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res23</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res23</span><span class="p">);</span> <span class="c1">// 'bike:3' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res24</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res24</span><span class="p">);</span> <span class="c1">// 'bike:1' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res25</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res25</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res26</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res26</span><span class="p">);</span> <span class="c1">// None </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res27</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res28</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res29</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29</span><span class="p">);</span> <span class="c1">// ['bike:5', 'bike:4', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res27eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27eol</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res28eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28eol</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res29eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29eol</span><span class="p">);</span> <span class="c1">// ['bike:3', 'bike:4', 'bike:5'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res31</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res31</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res32</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res32</span><span class="p">);</span> <span class="c1">// { key: 'bikes:repairs', element: 'bike:2' } </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res33</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res33</span><span class="p">);</span> <span class="c1">// { key: 'bikes:repairs', element: 'bike:1' } </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res34</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res34</span><span class="p">);</span> <span class="c1">// null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res35</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res35</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res36</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res37</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res38</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">type</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res38</span><span class="p">);</span> <span class="c1">// 'string' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="k">try</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kr">const</span> <span class="nx">res39</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// redis.exceptions.ResponseError: </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ErrorReply: WRONGTYPE Operation against a key holding the wrong kind of value] </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="k">catch</span><span class="p">(</span><span class="nx">e</span><span class="p">){</span> </span></span><span class="line"><span class="cl"> <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">e</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res40</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">exists</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res40</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res41</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res41</span><span class="p">);</span> <span class="c1">// 'bike:3' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res42</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res42</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res43</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res43</span><span class="p">);</span> <span class="c1">// 'bike:1' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res44</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">exists</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res44</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res45</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res45</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res46</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lLen</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res46</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res47</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res47</span><span class="p">);</span> <span class="c1">// null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res48</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res48</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res49</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res49</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res50</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res50</span><span class="p">);</span> <span class="c1">// ['bike:5', 'bike:4', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_list_tutorial-stepqueue')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_list_tutorial-stepqueue" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-list.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_list_tutorial-stepqueue" name="list_tutorial-stepqueue" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_list_tutorial-stepqueue" title="Open example"> Java </label> <div aria-labelledby="tab-list_tutorial-stepqueue" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_list_tutorial-stepqueue" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nn">io.redis.examples</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.junit.Test</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.args.ListDirection</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.List</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.*</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">ListExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">llen</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lmove</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bikes:finished"</span><span class="o">,</span> <span class="n">ListDirection</span><span class="o">.</span><span class="na">LEFT</span><span class="o">,</span> <span class="n">ListDirection</span><span class="o">.</span><span class="na">LEFT</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res13</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:finished"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res14</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res15</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res16</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res16</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:important_bike"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res17</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:important_bike, bike:1, bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res19</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:important_bike"</span><span class="o">,</span> <span class="s">"bike:very_important_bike"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res20</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res21</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res21</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:very_important_bike, bike:important_bike, bike:1, bike:2, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res22</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res22</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res23</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res23</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res24</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res24</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res25</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res25</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res26</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res26</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="mi">2</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res28</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:5, bike:4, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="o">-</span><span class="mi">3</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:3, bike:4, bike:5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res31</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res31</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res32</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span> <span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res32</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; (bikes:repairs, bike:2) </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res33</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res33</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; (bikes:repairs, bike:1) </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res34</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res34</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res35</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">del</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res35</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res36</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res37</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res37</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res38</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">type</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res38</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; string </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="k">try</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res39</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> <span class="k">catch</span> <span class="o">(</span><span class="n">Exception</span> <span class="n">e</span><span class="o">)</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">e</span><span class="o">.</span><span class="na">printStackTrace</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; redis.clients.jedis.exceptions.JedisDataException: </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="o">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res40</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">exists</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res40</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res41</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res41</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res42</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res42</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res43</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res43</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res44</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">exists</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res44</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res45</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">del</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res45</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res46</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">llen</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res46</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res47</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res47</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res48</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res48</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res49</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="mi">2</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res49</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res50</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res50</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:5, bike:4, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_list_tutorial-stepqueue')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_list_tutorial-stepqueue" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/ListExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_list_tutorial-stepqueue" name="list_tutorial-stepqueue" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_list_tutorial-stepqueue" title="Open example"> Go </label> <div aria-labelledby="tab-list_tutorial-stepqueue" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_list_tutorial-stepqueue" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_queue</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_stack</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_llen</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lmove_lrange</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LMove</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bikes:finished"</span><span class="p">,</span> <span class="s">"LEFT"</span><span class="p">,</span> <span class="s">"LEFT"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:finished"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lpush_rpush</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:important_bike bike:1 bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_variadic</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">,</span> <span class="s">"bike:very_important_bike"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:very_important_bike bike:important_bike bike:1 bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lpop_rpop</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res22</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res23</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res23</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res24</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res24</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res25</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res25</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res26</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res26</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;empty string&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res27</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res27</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res28</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res28</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res29</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res29</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:5 bike:4 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim_end_of_list</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res30</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res30</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res31</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res31</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res32</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res32</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:3 bike:4 bike:5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_brpop</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res33</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res33</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res34</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res34</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bikes:repairs bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res35</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res35</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bikes:repairs bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res36</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res36</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res37</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Del</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res37</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res38</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res38</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule11</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res39</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res39</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res40</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Type</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res40</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; string </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res41</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res41</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res42</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res42</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res43</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Exists</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res43</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res44</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res44</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res45</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res45</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res46</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res46</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res47</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Exists</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res47</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule3</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res48</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Del</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res48</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res49</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res49</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res50</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res50</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;empty string&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res51</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res51</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res52</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res52</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res53</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res53</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:5 bike:4 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_list_tutorial-stepqueue')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_list_tutorial-stepqueue" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/list_tutorial_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_list_tutorial-stepqueue" name="list_tutorial-stepqueue" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_list_tutorial-stepqueue" title="Open example"> C# </label> <div aria-labelledby="tab-list_tutorial-stepqueue" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_list_tutorial-stepqueue" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">ListExample</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res3</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res4</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res5</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res7</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res8</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLength</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res10</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListMove</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"{bikes}:finished"</span><span class="p">,</span> <span class="n">ListSide</span><span class="p">.</span><span class="n">Left</span><span class="p">,</span> <span class="n">ListSide</span><span class="p">.</span><span class="n">Left</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">Write</span><span class="p">(</span><span class="n">res12</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res13</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"{bikes}:finished"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res14</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res15</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res16</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res17</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res18</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:important_bike, bike:1, bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res19</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:important_bike"</span><span class="p">,</span> <span class="s">"bike:very_important_bike"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res20</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res21</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res21</span><span class="p">));</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; "bike:very_important_bike, bike:important_bike, bike:1, bike:2, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res22</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res22</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res23</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res23</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res24</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res24</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res25</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res25</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res26</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res26</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; &lt;Empty string&gt;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res27</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res27</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res28</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res28</span><span class="p">));</span> <span class="c1">// "bike:5, bike:4, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res29</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res29</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="p">-</span><span class="m">3</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res30</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res30</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:3, bike:4, bike:5"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res31</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res31</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res32</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="p">(</span><span class="n">res32</span> <span class="p">!=</span> <span class="k">null</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"{res32.Item1} -&gt; {res32.Item2}"</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bikes:repairs -&gt; bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res33</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="p">(</span><span class="n">res33</span> <span class="p">!=</span> <span class="k">null</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"{res33.Item1} -&gt; {res33.Item2}"</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bikes:repairs -&gt; bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res34</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res34</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "Null"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res35</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyDelete</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res35</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res36</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res36</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res37</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res37</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisType</span> <span class="n">res38</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyType</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res38</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; RedisType.String</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">try</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res39</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="k">catch</span> <span class="p">(</span><span class="n">Exception</span> <span class="n">e</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">e</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res40</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res40</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res41</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExists</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res41</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res42</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res42</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res43</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res43</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res44</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res44</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res45</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExists</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res45</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res46</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyDelete</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res46</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res47</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLength</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res47</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res48</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res48</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; Null</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res49</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res49</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res50</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res50</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:5, bike:4, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_list_tutorial-stepqueue')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_list_tutorial-stepqueue" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/ListTutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <p> </p> </li> <li> <p> Treat a list like a stack (first in, last out): </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="list_tutorial-stepstack"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_list_tutorial-stepstack" name="list_tutorial-stepstack" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_list_tutorial-stepstack" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-list_tutorial-stepstack" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_list_tutorial-stepstack" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; LPUSH bikes:repairs bike:1 </span></span><span class="line hl"><span class="cl">(integer) 1 </span></span><span class="line hl"><span class="cl">&gt; LPUSH bikes:repairs bike:2 </span></span><span class="line hl"><span class="cl">(integer) 2 </span></span><span class="line hl"><span class="cl">&gt; LPOP bikes:repairs </span></span><span class="line hl"><span class="cl">"bike:2" </span></span><span class="line hl"><span class="cl">&gt; LPOP bikes:repairs </span></span><span class="line hl"><span class="cl">"bike:1"</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_list_tutorial-stepstack')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_list_tutorial-stepstack" name="list_tutorial-stepstack" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_list_tutorial-stepstack" title="Open example"> Python </label> <div aria-labelledby="tab-list_tutorial-stepstack" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_list_tutorial-stepstack" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for List doc pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/lists/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:2</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">llen</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lmove</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bikes:finished"</span><span class="p">,</span> <span class="s2">"LEFT"</span><span class="p">,</span> <span class="s2">"LEFT"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:1']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:finished"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:2']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:important_bike"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res18</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:important_bike', 'bike:1', 'bike:2']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:important_bike"</span><span class="p">,</span> <span class="s2">"bike:very_important_bike"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="n">res21</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:very_important_bike', 'bike:important_bike', 'bike:1', ...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res22</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res22</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res23</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res23</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:3'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res24</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res24</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:1'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res25</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res25</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res26</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res26</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res28</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res28</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res29</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res29</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:5', 'bike:4', 'bike:3']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res28</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res28</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res29</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res29</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:3', 'bike:4', 'bike:5']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res31</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res31</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res32</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res32</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ('bikes:repairs', 'bike:2')</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res33</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res33</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ('bikes:repairs', 'bike:1')</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res34</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res34</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res35</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res35</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res36</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res36</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res37</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res37</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res38</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">type</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res38</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'string'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">try</span><span class="p">:</span> </span></span><span class="line"><span class="cl"> <span class="n">res39</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1"># &gt;&gt;&gt; redis.exceptions.ResponseError:</span> </span></span><span class="line"><span class="cl"> <span class="c1"># &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value</span> </span></span><span class="line"><span class="cl"><span class="k">except</span> <span class="n">redis</span><span class="o">.</span><span class="n">exceptions</span><span class="o">.</span><span class="n">ResponseError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> </span></span><span class="line"><span class="cl"> <span class="nb">print</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res36</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res40</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res40</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res41</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res41</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:3'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res42</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res42</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res43</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res43</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:1'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res44</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res44</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res45</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res45</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res46</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">llen</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res46</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res47</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res47</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res48</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res48</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res49</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res49</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res50</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res50</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:5', 'bike:4', 'bike:3']</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_list_tutorial-stepstack')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_list_tutorial-stepstack" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_list.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_list_tutorial-stepstack" name="list_tutorial-stepstack" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_list_tutorial-stepstack" title="Open example"> Node.js </label> <div aria-labelledby="tab-list_tutorial-stepstack" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_list_tutorial-stepstack" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">createClient</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">);</span> <span class="c1">// bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">);</span> <span class="c1">// bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">);</span> <span class="c1">// bike:2 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">);</span> <span class="c1">// bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lLen</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lMove</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bikes:finished'</span><span class="p">,</span> <span class="s1">'LEFT'</span><span class="p">,</span> <span class="s1">'LEFT'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res13</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res13</span><span class="p">);</span> <span class="c1">// ['bike:1'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:finished'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res14</span><span class="p">);</span> <span class="c1">// ['bike:2'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res15</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res15</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res16</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res16</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res17</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:important_bike'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res17</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res18</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res18</span><span class="p">);</span> <span class="c1">// ['bike:important_bike', 'bike:1', 'bike:2'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res19</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:important_bike'</span><span class="p">,</span> <span class="s1">'bike:very_important_bike'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res20</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res21</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res21</span><span class="p">);</span> <span class="c1">// ['bike:very_important_bike', 'bike:important_bike', 'bike:1', 'bike:2', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res22</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res22</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res23</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res23</span><span class="p">);</span> <span class="c1">// 'bike:3' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res24</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res24</span><span class="p">);</span> <span class="c1">// 'bike:1' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res25</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res25</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res26</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res26</span><span class="p">);</span> <span class="c1">// None </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res27</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res28</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res29</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29</span><span class="p">);</span> <span class="c1">// ['bike:5', 'bike:4', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res27eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27eol</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res28eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28eol</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res29eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29eol</span><span class="p">);</span> <span class="c1">// ['bike:3', 'bike:4', 'bike:5'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res31</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res31</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res32</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res32</span><span class="p">);</span> <span class="c1">// { key: 'bikes:repairs', element: 'bike:2' } </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res33</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res33</span><span class="p">);</span> <span class="c1">// { key: 'bikes:repairs', element: 'bike:1' } </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res34</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res34</span><span class="p">);</span> <span class="c1">// null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res35</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res35</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res36</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res37</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res38</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">type</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res38</span><span class="p">);</span> <span class="c1">// 'string' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="k">try</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kr">const</span> <span class="nx">res39</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// redis.exceptions.ResponseError: </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ErrorReply: WRONGTYPE Operation against a key holding the wrong kind of value] </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="k">catch</span><span class="p">(</span><span class="nx">e</span><span class="p">){</span> </span></span><span class="line"><span class="cl"> <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">e</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res40</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">exists</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res40</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res41</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res41</span><span class="p">);</span> <span class="c1">// 'bike:3' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res42</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res42</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res43</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res43</span><span class="p">);</span> <span class="c1">// 'bike:1' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res44</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">exists</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res44</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res45</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res45</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res46</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lLen</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res46</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res47</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res47</span><span class="p">);</span> <span class="c1">// null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res48</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res48</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res49</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res49</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res50</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res50</span><span class="p">);</span> <span class="c1">// ['bike:5', 'bike:4', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_list_tutorial-stepstack')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_list_tutorial-stepstack" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-list.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_list_tutorial-stepstack" name="list_tutorial-stepstack" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_list_tutorial-stepstack" title="Open example"> Java </label> <div aria-labelledby="tab-list_tutorial-stepstack" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_list_tutorial-stepstack" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nn">io.redis.examples</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.junit.Test</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.args.ListDirection</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.List</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.*</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">ListExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">llen</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lmove</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bikes:finished"</span><span class="o">,</span> <span class="n">ListDirection</span><span class="o">.</span><span class="na">LEFT</span><span class="o">,</span> <span class="n">ListDirection</span><span class="o">.</span><span class="na">LEFT</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res13</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:finished"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res14</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res15</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res16</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res16</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:important_bike"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res17</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:important_bike, bike:1, bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res19</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:important_bike"</span><span class="o">,</span> <span class="s">"bike:very_important_bike"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res20</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res21</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res21</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:very_important_bike, bike:important_bike, bike:1, bike:2, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res22</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res22</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res23</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res23</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res24</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res24</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res25</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res25</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res26</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res26</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="mi">2</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res28</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:5, bike:4, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="o">-</span><span class="mi">3</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:3, bike:4, bike:5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res31</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res31</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res32</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span> <span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res32</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; (bikes:repairs, bike:2) </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res33</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res33</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; (bikes:repairs, bike:1) </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res34</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res34</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res35</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">del</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res35</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res36</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res37</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res37</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res38</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">type</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res38</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; string </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="k">try</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res39</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> <span class="k">catch</span> <span class="o">(</span><span class="n">Exception</span> <span class="n">e</span><span class="o">)</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">e</span><span class="o">.</span><span class="na">printStackTrace</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; redis.clients.jedis.exceptions.JedisDataException: </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="o">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res40</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">exists</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res40</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res41</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res41</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res42</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res42</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res43</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res43</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res44</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">exists</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res44</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res45</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">del</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res45</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res46</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">llen</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res46</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res47</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res47</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res48</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res48</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res49</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="mi">2</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res49</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res50</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res50</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:5, bike:4, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_list_tutorial-stepstack')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_list_tutorial-stepstack" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/ListExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_list_tutorial-stepstack" name="list_tutorial-stepstack" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_list_tutorial-stepstack" title="Open example"> Go </label> <div aria-labelledby="tab-list_tutorial-stepstack" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_list_tutorial-stepstack" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_queue</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_stack</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_llen</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lmove_lrange</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LMove</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bikes:finished"</span><span class="p">,</span> <span class="s">"LEFT"</span><span class="p">,</span> <span class="s">"LEFT"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:finished"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lpush_rpush</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:important_bike bike:1 bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_variadic</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">,</span> <span class="s">"bike:very_important_bike"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:very_important_bike bike:important_bike bike:1 bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lpop_rpop</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res22</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res23</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res23</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res24</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res24</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res25</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res25</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res26</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res26</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;empty string&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res27</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res27</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res28</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res28</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res29</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res29</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:5 bike:4 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim_end_of_list</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res30</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res30</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res31</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res31</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res32</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res32</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:3 bike:4 bike:5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_brpop</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res33</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res33</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res34</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res34</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bikes:repairs bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res35</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res35</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bikes:repairs bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res36</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res36</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res37</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Del</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res37</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res38</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res38</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule11</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res39</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res39</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res40</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Type</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res40</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; string </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res41</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res41</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res42</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res42</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res43</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Exists</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res43</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res44</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res44</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res45</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res45</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res46</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res46</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res47</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Exists</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res47</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule3</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res48</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Del</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res48</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res49</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res49</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res50</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res50</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;empty string&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res51</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res51</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res52</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res52</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res53</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res53</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:5 bike:4 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_list_tutorial-stepstack')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_list_tutorial-stepstack" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/list_tutorial_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_list_tutorial-stepstack" name="list_tutorial-stepstack" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_list_tutorial-stepstack" title="Open example"> C# </label> <div aria-labelledby="tab-list_tutorial-stepstack" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_list_tutorial-stepstack" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">ListExample</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res3</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res4</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res5</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res7</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res8</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLength</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res10</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListMove</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"{bikes}:finished"</span><span class="p">,</span> <span class="n">ListSide</span><span class="p">.</span><span class="n">Left</span><span class="p">,</span> <span class="n">ListSide</span><span class="p">.</span><span class="n">Left</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">Write</span><span class="p">(</span><span class="n">res12</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res13</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"{bikes}:finished"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res14</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res15</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res16</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res17</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res18</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:important_bike, bike:1, bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res19</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:important_bike"</span><span class="p">,</span> <span class="s">"bike:very_important_bike"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res20</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res21</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res21</span><span class="p">));</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; "bike:very_important_bike, bike:important_bike, bike:1, bike:2, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res22</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res22</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res23</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res23</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res24</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res24</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res25</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res25</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res26</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res26</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; &lt;Empty string&gt;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res27</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res27</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res28</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res28</span><span class="p">));</span> <span class="c1">// "bike:5, bike:4, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res29</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res29</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="p">-</span><span class="m">3</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res30</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res30</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:3, bike:4, bike:5"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res31</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res31</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res32</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="p">(</span><span class="n">res32</span> <span class="p">!=</span> <span class="k">null</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"{res32.Item1} -&gt; {res32.Item2}"</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bikes:repairs -&gt; bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res33</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="p">(</span><span class="n">res33</span> <span class="p">!=</span> <span class="k">null</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"{res33.Item1} -&gt; {res33.Item2}"</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bikes:repairs -&gt; bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res34</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res34</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "Null"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res35</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyDelete</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res35</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res36</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res36</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res37</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res37</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisType</span> <span class="n">res38</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyType</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res38</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; RedisType.String</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">try</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res39</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="k">catch</span> <span class="p">(</span><span class="n">Exception</span> <span class="n">e</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">e</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res40</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res40</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res41</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExists</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res41</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res42</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res42</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res43</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res43</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res44</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res44</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res45</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExists</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res45</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res46</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyDelete</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res46</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res47</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLength</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res47</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res48</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res48</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; Null</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res49</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res49</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res50</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res50</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:5, bike:4, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_list_tutorial-stepstack')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_list_tutorial-stepstack" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/ListTutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <p> </p> </li> <li> <p> Check the length of a list: </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="list_tutorial-stepllen"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_list_tutorial-stepllen" name="list_tutorial-stepllen" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_list_tutorial-stepllen" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-list_tutorial-stepllen" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_list_tutorial-stepllen" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; LLEN bikes:repairs </span></span><span class="line hl"><span class="cl">(integer) 0</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_list_tutorial-stepllen')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_list_tutorial-stepllen" name="list_tutorial-stepllen" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_list_tutorial-stepllen" title="Open example"> Python </label> <div aria-labelledby="tab-list_tutorial-stepllen" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_list_tutorial-stepllen" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for List doc pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/lists/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">llen</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lmove</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bikes:finished"</span><span class="p">,</span> <span class="s2">"LEFT"</span><span class="p">,</span> <span class="s2">"LEFT"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:1']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:finished"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:2']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:important_bike"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res18</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:important_bike', 'bike:1', 'bike:2']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:important_bike"</span><span class="p">,</span> <span class="s2">"bike:very_important_bike"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="n">res21</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:very_important_bike', 'bike:important_bike', 'bike:1', ...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res22</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res22</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res23</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res23</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:3'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res24</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res24</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:1'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res25</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res25</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res26</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res26</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res28</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res28</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res29</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res29</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:5', 'bike:4', 'bike:3']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res28</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res28</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res29</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res29</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:3', 'bike:4', 'bike:5']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res31</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res31</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res32</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res32</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ('bikes:repairs', 'bike:2')</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res33</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res33</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ('bikes:repairs', 'bike:1')</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res34</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res34</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res35</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res35</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res36</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res36</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res37</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res37</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res38</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">type</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res38</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'string'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">try</span><span class="p">:</span> </span></span><span class="line"><span class="cl"> <span class="n">res39</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1"># &gt;&gt;&gt; redis.exceptions.ResponseError:</span> </span></span><span class="line"><span class="cl"> <span class="c1"># &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value</span> </span></span><span class="line"><span class="cl"><span class="k">except</span> <span class="n">redis</span><span class="o">.</span><span class="n">exceptions</span><span class="o">.</span><span class="n">ResponseError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> </span></span><span class="line"><span class="cl"> <span class="nb">print</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res36</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res40</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res40</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res41</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res41</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:3'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res42</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res42</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res43</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res43</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:1'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res44</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res44</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res45</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res45</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res46</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">llen</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res46</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res47</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res47</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res48</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res48</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res49</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res49</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res50</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res50</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:5', 'bike:4', 'bike:3']</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_list_tutorial-stepllen')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_list_tutorial-stepllen" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_list.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_list_tutorial-stepllen" name="list_tutorial-stepllen" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_list_tutorial-stepllen" title="Open example"> Node.js </label> <div aria-labelledby="tab-list_tutorial-stepllen" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_list_tutorial-stepllen" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">createClient</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">);</span> <span class="c1">// bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">);</span> <span class="c1">// bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">);</span> <span class="c1">// bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">);</span> <span class="c1">// bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lLen</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lMove</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bikes:finished'</span><span class="p">,</span> <span class="s1">'LEFT'</span><span class="p">,</span> <span class="s1">'LEFT'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res13</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res13</span><span class="p">);</span> <span class="c1">// ['bike:1'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:finished'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res14</span><span class="p">);</span> <span class="c1">// ['bike:2'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res15</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res15</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res16</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res16</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res17</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:important_bike'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res17</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res18</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res18</span><span class="p">);</span> <span class="c1">// ['bike:important_bike', 'bike:1', 'bike:2'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res19</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:important_bike'</span><span class="p">,</span> <span class="s1">'bike:very_important_bike'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res20</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res21</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res21</span><span class="p">);</span> <span class="c1">// ['bike:very_important_bike', 'bike:important_bike', 'bike:1', 'bike:2', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res22</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res22</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res23</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res23</span><span class="p">);</span> <span class="c1">// 'bike:3' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res24</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res24</span><span class="p">);</span> <span class="c1">// 'bike:1' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res25</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res25</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res26</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res26</span><span class="p">);</span> <span class="c1">// None </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res27</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res28</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res29</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29</span><span class="p">);</span> <span class="c1">// ['bike:5', 'bike:4', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res27eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27eol</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res28eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28eol</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res29eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29eol</span><span class="p">);</span> <span class="c1">// ['bike:3', 'bike:4', 'bike:5'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res31</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res31</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res32</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res32</span><span class="p">);</span> <span class="c1">// { key: 'bikes:repairs', element: 'bike:2' } </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res33</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res33</span><span class="p">);</span> <span class="c1">// { key: 'bikes:repairs', element: 'bike:1' } </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res34</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res34</span><span class="p">);</span> <span class="c1">// null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res35</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res35</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res36</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res37</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res38</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">type</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res38</span><span class="p">);</span> <span class="c1">// 'string' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="k">try</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kr">const</span> <span class="nx">res39</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// redis.exceptions.ResponseError: </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ErrorReply: WRONGTYPE Operation against a key holding the wrong kind of value] </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="k">catch</span><span class="p">(</span><span class="nx">e</span><span class="p">){</span> </span></span><span class="line"><span class="cl"> <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">e</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res40</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">exists</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res40</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res41</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res41</span><span class="p">);</span> <span class="c1">// 'bike:3' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res42</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res42</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res43</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res43</span><span class="p">);</span> <span class="c1">// 'bike:1' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res44</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">exists</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res44</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res45</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res45</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res46</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lLen</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res46</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res47</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res47</span><span class="p">);</span> <span class="c1">// null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res48</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res48</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res49</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res49</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res50</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res50</span><span class="p">);</span> <span class="c1">// ['bike:5', 'bike:4', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_list_tutorial-stepllen')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_list_tutorial-stepllen" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-list.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_list_tutorial-stepllen" name="list_tutorial-stepllen" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_list_tutorial-stepllen" title="Open example"> Java </label> <div aria-labelledby="tab-list_tutorial-stepllen" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_list_tutorial-stepllen" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nn">io.redis.examples</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.junit.Test</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.args.ListDirection</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.List</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.*</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">ListExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">llen</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lmove</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bikes:finished"</span><span class="o">,</span> <span class="n">ListDirection</span><span class="o">.</span><span class="na">LEFT</span><span class="o">,</span> <span class="n">ListDirection</span><span class="o">.</span><span class="na">LEFT</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res13</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:finished"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res14</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res15</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res16</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res16</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:important_bike"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res17</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:important_bike, bike:1, bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res19</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:important_bike"</span><span class="o">,</span> <span class="s">"bike:very_important_bike"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res20</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res21</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res21</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:very_important_bike, bike:important_bike, bike:1, bike:2, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res22</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res22</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res23</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res23</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res24</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res24</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res25</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res25</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res26</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res26</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="mi">2</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res28</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:5, bike:4, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="o">-</span><span class="mi">3</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:3, bike:4, bike:5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res31</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res31</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res32</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span> <span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res32</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; (bikes:repairs, bike:2) </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res33</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res33</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; (bikes:repairs, bike:1) </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res34</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res34</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res35</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">del</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res35</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res36</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res37</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res37</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res38</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">type</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res38</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; string </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="k">try</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res39</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> <span class="k">catch</span> <span class="o">(</span><span class="n">Exception</span> <span class="n">e</span><span class="o">)</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">e</span><span class="o">.</span><span class="na">printStackTrace</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; redis.clients.jedis.exceptions.JedisDataException: </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="o">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res40</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">exists</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res40</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res41</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res41</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res42</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res42</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res43</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res43</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res44</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">exists</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res44</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res45</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">del</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res45</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res46</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">llen</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res46</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res47</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res47</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res48</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res48</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res49</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="mi">2</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res49</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res50</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res50</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:5, bike:4, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_list_tutorial-stepllen')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_list_tutorial-stepllen" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/ListExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_list_tutorial-stepllen" name="list_tutorial-stepllen" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_list_tutorial-stepllen" title="Open example"> Go </label> <div aria-labelledby="tab-list_tutorial-stepllen" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_list_tutorial-stepllen" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_queue</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_stack</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_llen</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lmove_lrange</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LMove</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bikes:finished"</span><span class="p">,</span> <span class="s">"LEFT"</span><span class="p">,</span> <span class="s">"LEFT"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:finished"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lpush_rpush</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:important_bike bike:1 bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_variadic</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">,</span> <span class="s">"bike:very_important_bike"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:very_important_bike bike:important_bike bike:1 bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lpop_rpop</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res22</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res23</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res23</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res24</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res24</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res25</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res25</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res26</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res26</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;empty string&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res27</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res27</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res28</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res28</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res29</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res29</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:5 bike:4 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim_end_of_list</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res30</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res30</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res31</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res31</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res32</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res32</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:3 bike:4 bike:5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_brpop</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res33</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res33</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res34</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res34</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bikes:repairs bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res35</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res35</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bikes:repairs bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res36</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res36</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res37</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Del</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res37</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res38</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res38</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule11</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res39</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res39</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res40</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Type</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res40</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; string </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res41</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res41</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res42</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res42</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res43</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Exists</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res43</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res44</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res44</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res45</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res45</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res46</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res46</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res47</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Exists</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res47</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule3</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res48</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Del</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res48</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res49</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res49</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res50</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res50</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;empty string&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res51</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res51</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res52</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res52</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res53</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res53</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:5 bike:4 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_list_tutorial-stepllen')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_list_tutorial-stepllen" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/list_tutorial_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_list_tutorial-stepllen" name="list_tutorial-stepllen" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_list_tutorial-stepllen" title="Open example"> C# </label> <div aria-labelledby="tab-list_tutorial-stepllen" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_list_tutorial-stepllen" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">ListExample</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res3</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res4</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res5</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res7</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res8</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLength</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res10</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListMove</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"{bikes}:finished"</span><span class="p">,</span> <span class="n">ListSide</span><span class="p">.</span><span class="n">Left</span><span class="p">,</span> <span class="n">ListSide</span><span class="p">.</span><span class="n">Left</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">Write</span><span class="p">(</span><span class="n">res12</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res13</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"{bikes}:finished"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res14</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res15</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res16</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res17</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res18</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:important_bike, bike:1, bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res19</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:important_bike"</span><span class="p">,</span> <span class="s">"bike:very_important_bike"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res20</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res21</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res21</span><span class="p">));</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; "bike:very_important_bike, bike:important_bike, bike:1, bike:2, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res22</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res22</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res23</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res23</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res24</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res24</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res25</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res25</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res26</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res26</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; &lt;Empty string&gt;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res27</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res27</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res28</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res28</span><span class="p">));</span> <span class="c1">// "bike:5, bike:4, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res29</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res29</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="p">-</span><span class="m">3</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res30</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res30</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:3, bike:4, bike:5"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res31</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res31</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res32</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="p">(</span><span class="n">res32</span> <span class="p">!=</span> <span class="k">null</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"{res32.Item1} -&gt; {res32.Item2}"</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bikes:repairs -&gt; bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res33</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="p">(</span><span class="n">res33</span> <span class="p">!=</span> <span class="k">null</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"{res33.Item1} -&gt; {res33.Item2}"</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bikes:repairs -&gt; bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res34</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res34</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "Null"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res35</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyDelete</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res35</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res36</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res36</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res37</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res37</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisType</span> <span class="n">res38</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyType</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res38</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; RedisType.String</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">try</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res39</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="k">catch</span> <span class="p">(</span><span class="n">Exception</span> <span class="n">e</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">e</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res40</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res40</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res41</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExists</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res41</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res42</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res42</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res43</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res43</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res44</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res44</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res45</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExists</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res45</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res46</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyDelete</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res46</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res47</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLength</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res47</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res48</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res48</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; Null</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res49</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res49</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res50</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res50</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:5, bike:4, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_list_tutorial-stepllen')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_list_tutorial-stepllen" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/ListTutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <p> </p> </li> <li> <p> Atomically pop an element from one list and push to another: </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="list_tutorial-steplmove_lrange"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_list_tutorial-steplmove_lrange" name="list_tutorial-steplmove_lrange" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_list_tutorial-steplmove_lrange" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-list_tutorial-steplmove_lrange" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_list_tutorial-steplmove_lrange" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; LPUSH bikes:repairs bike:1 </span></span><span class="line hl"><span class="cl">(integer) 1 </span></span><span class="line hl"><span class="cl">&gt; LPUSH bikes:repairs bike:2 </span></span><span class="line hl"><span class="cl">(integer) 2 </span></span><span class="line hl"><span class="cl">&gt; LMOVE bikes:repairs bikes:finished LEFT LEFT </span></span><span class="line hl"><span class="cl">"bike:2" </span></span><span class="line hl"><span class="cl">&gt; LRANGE bikes:repairs 0 -1 </span></span><span class="line hl"><span class="cl">1) "bike:1" </span></span><span class="line hl"><span class="cl">&gt; LRANGE bikes:finished 0 -1 </span></span><span class="line hl"><span class="cl">1) "bike:2"</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_list_tutorial-steplmove_lrange')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_list_tutorial-steplmove_lrange" name="list_tutorial-steplmove_lrange" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_list_tutorial-steplmove_lrange" title="Open example"> Python </label> <div aria-labelledby="tab-list_tutorial-steplmove_lrange" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_list_tutorial-steplmove_lrange" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for List doc pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/lists/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">llen</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lmove</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bikes:finished"</span><span class="p">,</span> <span class="s2">"LEFT"</span><span class="p">,</span> <span class="s2">"LEFT"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:1']</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:finished"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:2']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:important_bike"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res18</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:important_bike', 'bike:1', 'bike:2']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:important_bike"</span><span class="p">,</span> <span class="s2">"bike:very_important_bike"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="n">res21</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:very_important_bike', 'bike:important_bike', 'bike:1', ...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res22</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res22</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res23</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res23</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:3'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res24</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res24</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:1'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res25</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res25</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res26</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res26</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res28</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res28</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res29</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res29</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:5', 'bike:4', 'bike:3']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res28</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res28</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res29</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res29</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:3', 'bike:4', 'bike:5']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res31</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res31</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res32</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res32</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ('bikes:repairs', 'bike:2')</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res33</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res33</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ('bikes:repairs', 'bike:1')</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res34</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res34</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res35</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res35</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res36</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res36</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res37</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res37</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res38</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">type</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res38</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'string'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">try</span><span class="p">:</span> </span></span><span class="line"><span class="cl"> <span class="n">res39</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1"># &gt;&gt;&gt; redis.exceptions.ResponseError:</span> </span></span><span class="line"><span class="cl"> <span class="c1"># &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value</span> </span></span><span class="line"><span class="cl"><span class="k">except</span> <span class="n">redis</span><span class="o">.</span><span class="n">exceptions</span><span class="o">.</span><span class="n">ResponseError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> </span></span><span class="line"><span class="cl"> <span class="nb">print</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res36</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res40</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res40</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res41</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res41</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:3'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res42</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res42</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res43</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res43</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:1'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res44</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res44</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res45</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res45</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res46</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">llen</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res46</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res47</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res47</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res48</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res48</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res49</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res49</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res50</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res50</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:5', 'bike:4', 'bike:3']</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_list_tutorial-steplmove_lrange')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_list_tutorial-steplmove_lrange" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_list.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_list_tutorial-steplmove_lrange" name="list_tutorial-steplmove_lrange" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_list_tutorial-steplmove_lrange" title="Open example"> Node.js </label> <div aria-labelledby="tab-list_tutorial-steplmove_lrange" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_list_tutorial-steplmove_lrange" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">createClient</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">);</span> <span class="c1">// bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">);</span> <span class="c1">// bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">);</span> <span class="c1">// bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">);</span> <span class="c1">// bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lLen</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lMove</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bikes:finished'</span><span class="p">,</span> <span class="s1">'LEFT'</span><span class="p">,</span> <span class="s1">'LEFT'</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res13</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res13</span><span class="p">);</span> <span class="c1">// ['bike:1'] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:finished'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res14</span><span class="p">);</span> <span class="c1">// ['bike:2'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res15</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res15</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res16</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res16</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res17</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:important_bike'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res17</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res18</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res18</span><span class="p">);</span> <span class="c1">// ['bike:important_bike', 'bike:1', 'bike:2'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res19</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:important_bike'</span><span class="p">,</span> <span class="s1">'bike:very_important_bike'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res20</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res21</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res21</span><span class="p">);</span> <span class="c1">// ['bike:very_important_bike', 'bike:important_bike', 'bike:1', 'bike:2', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res22</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res22</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res23</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res23</span><span class="p">);</span> <span class="c1">// 'bike:3' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res24</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res24</span><span class="p">);</span> <span class="c1">// 'bike:1' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res25</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res25</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res26</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res26</span><span class="p">);</span> <span class="c1">// None </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res27</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res28</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res29</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29</span><span class="p">);</span> <span class="c1">// ['bike:5', 'bike:4', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res27eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27eol</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res28eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28eol</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res29eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29eol</span><span class="p">);</span> <span class="c1">// ['bike:3', 'bike:4', 'bike:5'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res31</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res31</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res32</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res32</span><span class="p">);</span> <span class="c1">// { key: 'bikes:repairs', element: 'bike:2' } </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res33</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res33</span><span class="p">);</span> <span class="c1">// { key: 'bikes:repairs', element: 'bike:1' } </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res34</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res34</span><span class="p">);</span> <span class="c1">// null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res35</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res35</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res36</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res37</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res38</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">type</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res38</span><span class="p">);</span> <span class="c1">// 'string' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="k">try</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kr">const</span> <span class="nx">res39</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// redis.exceptions.ResponseError: </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ErrorReply: WRONGTYPE Operation against a key holding the wrong kind of value] </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="k">catch</span><span class="p">(</span><span class="nx">e</span><span class="p">){</span> </span></span><span class="line"><span class="cl"> <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">e</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res40</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">exists</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res40</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res41</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res41</span><span class="p">);</span> <span class="c1">// 'bike:3' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res42</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res42</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res43</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res43</span><span class="p">);</span> <span class="c1">// 'bike:1' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res44</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">exists</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res44</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res45</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res45</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res46</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lLen</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res46</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res47</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res47</span><span class="p">);</span> <span class="c1">// null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res48</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res48</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res49</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res49</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res50</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res50</span><span class="p">);</span> <span class="c1">// ['bike:5', 'bike:4', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_list_tutorial-steplmove_lrange')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_list_tutorial-steplmove_lrange" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-list.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_list_tutorial-steplmove_lrange" name="list_tutorial-steplmove_lrange" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_list_tutorial-steplmove_lrange" title="Open example"> Java </label> <div aria-labelledby="tab-list_tutorial-steplmove_lrange" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_list_tutorial-steplmove_lrange" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nn">io.redis.examples</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.junit.Test</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.args.ListDirection</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.List</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.*</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">ListExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">llen</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lmove</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bikes:finished"</span><span class="o">,</span> <span class="n">ListDirection</span><span class="o">.</span><span class="na">LEFT</span><span class="o">,</span> <span class="n">ListDirection</span><span class="o">.</span><span class="na">LEFT</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res13</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:finished"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res14</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res15</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res16</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res16</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:important_bike"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res17</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:important_bike, bike:1, bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res19</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:important_bike"</span><span class="o">,</span> <span class="s">"bike:very_important_bike"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res20</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res21</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res21</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:very_important_bike, bike:important_bike, bike:1, bike:2, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res22</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res22</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res23</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res23</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res24</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res24</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res25</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res25</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res26</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res26</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="mi">2</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res28</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:5, bike:4, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="o">-</span><span class="mi">3</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:3, bike:4, bike:5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res31</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res31</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res32</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span> <span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res32</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; (bikes:repairs, bike:2) </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res33</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res33</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; (bikes:repairs, bike:1) </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res34</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res34</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res35</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">del</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res35</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res36</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res37</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res37</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res38</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">type</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res38</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; string </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="k">try</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res39</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> <span class="k">catch</span> <span class="o">(</span><span class="n">Exception</span> <span class="n">e</span><span class="o">)</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">e</span><span class="o">.</span><span class="na">printStackTrace</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; redis.clients.jedis.exceptions.JedisDataException: </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="o">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res40</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">exists</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res40</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res41</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res41</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res42</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res42</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res43</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res43</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res44</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">exists</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res44</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res45</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">del</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res45</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res46</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">llen</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res46</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res47</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res47</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res48</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res48</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res49</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="mi">2</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res49</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res50</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res50</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:5, bike:4, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_list_tutorial-steplmove_lrange')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_list_tutorial-steplmove_lrange" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/ListExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_list_tutorial-steplmove_lrange" name="list_tutorial-steplmove_lrange" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_list_tutorial-steplmove_lrange" title="Open example"> Go </label> <div aria-labelledby="tab-list_tutorial-steplmove_lrange" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_list_tutorial-steplmove_lrange" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_queue</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_stack</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_llen</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lmove_lrange</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LMove</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bikes:finished"</span><span class="p">,</span> <span class="s">"LEFT"</span><span class="p">,</span> <span class="s">"LEFT"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:finished"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lpush_rpush</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:important_bike bike:1 bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_variadic</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">,</span> <span class="s">"bike:very_important_bike"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:very_important_bike bike:important_bike bike:1 bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lpop_rpop</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res22</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res23</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res23</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res24</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res24</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res25</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res25</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res26</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res26</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;empty string&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res27</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res27</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res28</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res28</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res29</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res29</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:5 bike:4 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim_end_of_list</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res30</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res30</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res31</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res31</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res32</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res32</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:3 bike:4 bike:5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_brpop</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res33</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res33</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res34</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res34</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bikes:repairs bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res35</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res35</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bikes:repairs bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res36</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res36</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res37</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Del</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res37</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res38</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res38</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule11</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res39</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res39</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res40</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Type</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res40</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; string </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res41</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res41</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res42</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res42</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res43</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Exists</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res43</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res44</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res44</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res45</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res45</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res46</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res46</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res47</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Exists</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res47</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule3</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res48</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Del</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res48</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res49</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res49</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res50</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res50</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;empty string&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res51</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res51</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res52</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res52</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res53</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res53</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:5 bike:4 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_list_tutorial-steplmove_lrange')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_list_tutorial-steplmove_lrange" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/list_tutorial_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_list_tutorial-steplmove_lrange" name="list_tutorial-steplmove_lrange" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_list_tutorial-steplmove_lrange" title="Open example"> C# </label> <div aria-labelledby="tab-list_tutorial-steplmove_lrange" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_list_tutorial-steplmove_lrange" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">ListExample</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res3</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res4</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res5</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res7</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res8</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLength</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res10</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListMove</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"{bikes}:finished"</span><span class="p">,</span> <span class="n">ListSide</span><span class="p">.</span><span class="n">Left</span><span class="p">,</span> <span class="n">ListSide</span><span class="p">.</span><span class="n">Left</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">Write</span><span class="p">(</span><span class="n">res12</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res13</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"{bikes}:finished"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res14</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res15</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res16</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res17</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res18</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:important_bike, bike:1, bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res19</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:important_bike"</span><span class="p">,</span> <span class="s">"bike:very_important_bike"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res20</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res21</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res21</span><span class="p">));</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; "bike:very_important_bike, bike:important_bike, bike:1, bike:2, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res22</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res22</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res23</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res23</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res24</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res24</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res25</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res25</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res26</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res26</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; &lt;Empty string&gt;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res27</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res27</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res28</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res28</span><span class="p">));</span> <span class="c1">// "bike:5, bike:4, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res29</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res29</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="p">-</span><span class="m">3</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res30</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res30</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:3, bike:4, bike:5"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res31</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res31</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res32</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="p">(</span><span class="n">res32</span> <span class="p">!=</span> <span class="k">null</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"{res32.Item1} -&gt; {res32.Item2}"</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bikes:repairs -&gt; bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res33</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="p">(</span><span class="n">res33</span> <span class="p">!=</span> <span class="k">null</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"{res33.Item1} -&gt; {res33.Item2}"</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bikes:repairs -&gt; bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res34</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res34</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "Null"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res35</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyDelete</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res35</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res36</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res36</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res37</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res37</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisType</span> <span class="n">res38</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyType</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res38</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; RedisType.String</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">try</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res39</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="k">catch</span> <span class="p">(</span><span class="n">Exception</span> <span class="n">e</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">e</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res40</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res40</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res41</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExists</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res41</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res42</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res42</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res43</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res43</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res44</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res44</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res45</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExists</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res45</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res46</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyDelete</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res46</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res47</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLength</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res47</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res48</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res48</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; Null</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res49</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res49</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res50</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res50</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:5, bike:4, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_list_tutorial-steplmove_lrange')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_list_tutorial-steplmove_lrange" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/ListTutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <p> </p> </li> <li> <p> To limit the length of a list you can call <a href="/docs/latest/commands/ltrim/"> <code> LTRIM </code> </a> : </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="list_tutorial-stepltrim.1"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_list_tutorial-stepltrim.1" name="list_tutorial-stepltrim.1" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_list_tutorial-stepltrim.1" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-list_tutorial-stepltrim.1" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_list_tutorial-stepltrim.1" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; RPUSH bikes:repairs bike:1 bike:2 bike:3 bike:4 bike:5 </span></span><span class="line hl"><span class="cl">(integer) 5 </span></span><span class="line hl"><span class="cl">&gt; LTRIM bikes:repairs 0 2 </span></span><span class="line hl"><span class="cl">OK </span></span><span class="line hl"><span class="cl">&gt; LRANGE bikes:repairs 0 -1 </span></span><span class="line hl"><span class="cl">1) "bike:1" </span></span><span class="line hl"><span class="cl">2) "bike:2" </span></span><span class="line hl"><span class="cl">3) "bike:3"</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_list_tutorial-stepltrim.1')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_list_tutorial-stepltrim.1" name="list_tutorial-stepltrim.1" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_list_tutorial-stepltrim.1" title="Open example"> Python </label> <div aria-labelledby="tab-list_tutorial-stepltrim.1" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_list_tutorial-stepltrim.1" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for List doc pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/lists/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">llen</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lmove</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bikes:finished"</span><span class="p">,</span> <span class="s2">"LEFT"</span><span class="p">,</span> <span class="s2">"LEFT"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:1']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:finished"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:2']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:important_bike"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res18</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:important_bike', 'bike:1', 'bike:2']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:important_bike"</span><span class="p">,</span> <span class="s2">"bike:very_important_bike"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="n">res21</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:very_important_bike', 'bike:important_bike', 'bike:1', ...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res22</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res22</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res23</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res23</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:3'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res24</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res24</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:1'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res25</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res25</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res26</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res26</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res28</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res28</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res29</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res29</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:5', 'bike:4', 'bike:3']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res28</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res28</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res29</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res29</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:3', 'bike:4', 'bike:5']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res31</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res31</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res32</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res32</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ('bikes:repairs', 'bike:2')</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res33</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res33</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ('bikes:repairs', 'bike:1')</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res34</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res34</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res35</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res35</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res36</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res36</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res37</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res37</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res38</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">type</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res38</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'string'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">try</span><span class="p">:</span> </span></span><span class="line"><span class="cl"> <span class="n">res39</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1"># &gt;&gt;&gt; redis.exceptions.ResponseError:</span> </span></span><span class="line"><span class="cl"> <span class="c1"># &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value</span> </span></span><span class="line"><span class="cl"><span class="k">except</span> <span class="n">redis</span><span class="o">.</span><span class="n">exceptions</span><span class="o">.</span><span class="n">ResponseError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> </span></span><span class="line"><span class="cl"> <span class="nb">print</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res36</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res40</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res40</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res41</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res41</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:3'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res42</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res42</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res43</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res43</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:1'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res44</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res44</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res45</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res45</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res46</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">llen</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res46</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res47</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res47</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res48</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res48</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res49</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res49</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res50</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res50</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:5', 'bike:4', 'bike:3']</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_list_tutorial-stepltrim.1')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_list_tutorial-stepltrim.1" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_list.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_list_tutorial-stepltrim.1" name="list_tutorial-stepltrim.1" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_list_tutorial-stepltrim.1" title="Open example"> Node.js </label> <div aria-labelledby="tab-list_tutorial-stepltrim.1" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_list_tutorial-stepltrim.1" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">createClient</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">);</span> <span class="c1">// bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">);</span> <span class="c1">// bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">);</span> <span class="c1">// bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">);</span> <span class="c1">// bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lLen</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lMove</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bikes:finished'</span><span class="p">,</span> <span class="s1">'LEFT'</span><span class="p">,</span> <span class="s1">'LEFT'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res13</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res13</span><span class="p">);</span> <span class="c1">// ['bike:1'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:finished'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res14</span><span class="p">);</span> <span class="c1">// ['bike:2'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res15</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res15</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res16</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res16</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res17</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:important_bike'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res17</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res18</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res18</span><span class="p">);</span> <span class="c1">// ['bike:important_bike', 'bike:1', 'bike:2'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res19</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:important_bike'</span><span class="p">,</span> <span class="s1">'bike:very_important_bike'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res20</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res21</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res21</span><span class="p">);</span> <span class="c1">// ['bike:very_important_bike', 'bike:important_bike', 'bike:1', 'bike:2', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res22</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res22</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res23</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res23</span><span class="p">);</span> <span class="c1">// 'bike:3' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res24</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res24</span><span class="p">);</span> <span class="c1">// 'bike:1' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res25</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res25</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res26</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res26</span><span class="p">);</span> <span class="c1">// None </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res27</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res28</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res29</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29</span><span class="p">);</span> <span class="c1">// ['bike:5', 'bike:4', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res27eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27eol</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res28eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28eol</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res29eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29eol</span><span class="p">);</span> <span class="c1">// ['bike:3', 'bike:4', 'bike:5'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res31</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res31</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res32</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res32</span><span class="p">);</span> <span class="c1">// { key: 'bikes:repairs', element: 'bike:2' } </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res33</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res33</span><span class="p">);</span> <span class="c1">// { key: 'bikes:repairs', element: 'bike:1' } </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res34</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res34</span><span class="p">);</span> <span class="c1">// null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res35</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res35</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res36</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res37</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res38</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">type</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res38</span><span class="p">);</span> <span class="c1">// 'string' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="k">try</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kr">const</span> <span class="nx">res39</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// redis.exceptions.ResponseError: </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ErrorReply: WRONGTYPE Operation against a key holding the wrong kind of value] </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="k">catch</span><span class="p">(</span><span class="nx">e</span><span class="p">){</span> </span></span><span class="line"><span class="cl"> <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">e</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res40</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">exists</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res40</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res41</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res41</span><span class="p">);</span> <span class="c1">// 'bike:3' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res42</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res42</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res43</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res43</span><span class="p">);</span> <span class="c1">// 'bike:1' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res44</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">exists</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res44</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res45</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res45</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res46</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lLen</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res46</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res47</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res47</span><span class="p">);</span> <span class="c1">// null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res48</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line hl"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line hl"><span class="cl"><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res48</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res49</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res49</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res50</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res50</span><span class="p">);</span> <span class="c1">// ['bike:5', 'bike:4', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_list_tutorial-stepltrim.1')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_list_tutorial-stepltrim.1" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-list.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_list_tutorial-stepltrim.1" name="list_tutorial-stepltrim.1" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_list_tutorial-stepltrim.1" title="Open example"> Java </label> <div aria-labelledby="tab-list_tutorial-stepltrim.1" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_list_tutorial-stepltrim.1" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nn">io.redis.examples</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.junit.Test</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.args.ListDirection</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.List</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.*</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">ListExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">llen</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lmove</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bikes:finished"</span><span class="o">,</span> <span class="n">ListDirection</span><span class="o">.</span><span class="na">LEFT</span><span class="o">,</span> <span class="n">ListDirection</span><span class="o">.</span><span class="na">LEFT</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res13</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:finished"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res14</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res15</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res16</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res16</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:important_bike"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res17</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:important_bike, bike:1, bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res19</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:important_bike"</span><span class="o">,</span> <span class="s">"bike:very_important_bike"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res20</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res21</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res21</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:very_important_bike, bike:important_bike, bike:1, bike:2, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res22</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res22</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res23</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res23</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res24</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res24</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res25</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res25</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res26</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res26</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="mi">2</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res28</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:5, bike:4, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="o">-</span><span class="mi">3</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:3, bike:4, bike:5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res31</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res31</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res32</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span> <span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res32</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; (bikes:repairs, bike:2) </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res33</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res33</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; (bikes:repairs, bike:1) </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res34</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res34</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res35</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">del</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res35</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res36</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res37</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res37</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res38</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">type</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res38</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; string </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="k">try</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res39</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> <span class="k">catch</span> <span class="o">(</span><span class="n">Exception</span> <span class="n">e</span><span class="o">)</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">e</span><span class="o">.</span><span class="na">printStackTrace</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; redis.clients.jedis.exceptions.JedisDataException: </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="o">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res40</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">exists</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res40</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res41</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res41</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res42</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res42</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res43</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res43</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res44</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">exists</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res44</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res45</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">del</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res45</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res46</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">llen</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res46</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res47</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res47</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res48</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res48</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">res49</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="mi">2</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res49</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res50</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res50</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:5, bike:4, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_list_tutorial-stepltrim.1')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_list_tutorial-stepltrim.1" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/ListExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_list_tutorial-stepltrim.1" name="list_tutorial-stepltrim.1" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_list_tutorial-stepltrim.1" title="Open example"> Go </label> <div aria-labelledby="tab-list_tutorial-stepltrim.1" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_list_tutorial-stepltrim.1" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_queue</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_stack</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_llen</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lmove_lrange</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LMove</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bikes:finished"</span><span class="p">,</span> <span class="s">"LEFT"</span><span class="p">,</span> <span class="s">"LEFT"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:finished"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lpush_rpush</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:important_bike bike:1 bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_variadic</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">,</span> <span class="s">"bike:very_important_bike"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:very_important_bike bike:important_bike bike:1 bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lpop_rpop</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res22</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res23</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res23</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res24</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res24</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res25</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res25</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res26</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res26</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;empty string&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res27</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res27</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res28</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res28</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res29</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res29</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:5 bike:4 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim_end_of_list</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res30</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res30</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res31</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res31</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res32</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res32</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:3 bike:4 bike:5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_brpop</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res33</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res33</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res34</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res34</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bikes:repairs bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res35</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res35</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bikes:repairs bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res36</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res36</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res37</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Del</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res37</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res38</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res38</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule11</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res39</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res39</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res40</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Type</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res40</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; string </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res41</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res41</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res42</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res42</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res43</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Exists</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res43</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res44</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res44</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res45</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res45</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res46</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res46</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res47</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Exists</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res47</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule3</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res48</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Del</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res48</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res49</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res49</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res50</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res50</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;empty string&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res51</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res51</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res52</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res52</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res53</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res53</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:5 bike:4 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_list_tutorial-stepltrim.1')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_list_tutorial-stepltrim.1" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/list_tutorial_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_list_tutorial-stepltrim.1" name="list_tutorial-stepltrim.1" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_list_tutorial-stepltrim.1" title="Open example"> C# </label> <div aria-labelledby="tab-list_tutorial-stepltrim.1" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_list_tutorial-stepltrim.1" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">ListExample</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res3</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res4</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res5</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res7</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res8</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLength</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res10</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListMove</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"{bikes}:finished"</span><span class="p">,</span> <span class="n">ListSide</span><span class="p">.</span><span class="n">Left</span><span class="p">,</span> <span class="n">ListSide</span><span class="p">.</span><span class="n">Left</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">Write</span><span class="p">(</span><span class="n">res12</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res13</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"{bikes}:finished"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res14</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res15</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res16</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res17</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res18</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:important_bike, bike:1, bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res19</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:important_bike"</span><span class="p">,</span> <span class="s">"bike:very_important_bike"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res20</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res21</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res21</span><span class="p">));</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; "bike:very_important_bike, bike:important_bike, bike:1, bike:2, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res22</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res22</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res23</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res23</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res24</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res24</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res25</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res25</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res26</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res26</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; &lt;Empty string&gt;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res27</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res27</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res28</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res28</span><span class="p">));</span> <span class="c1">// "bike:5, bike:4, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res29</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res29</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="p">-</span><span class="m">3</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res30</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res30</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:3, bike:4, bike:5"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res31</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res31</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res32</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="p">(</span><span class="n">res32</span> <span class="p">!=</span> <span class="k">null</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"{res32.Item1} -&gt; {res32.Item2}"</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bikes:repairs -&gt; bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res33</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="p">(</span><span class="n">res33</span> <span class="p">!=</span> <span class="k">null</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"{res33.Item1} -&gt; {res33.Item2}"</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bikes:repairs -&gt; bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res34</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res34</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "Null"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res35</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyDelete</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res35</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res36</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res36</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res37</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res37</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisType</span> <span class="n">res38</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyType</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res38</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; RedisType.String</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">try</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res39</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="k">catch</span> <span class="p">(</span><span class="n">Exception</span> <span class="n">e</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">e</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res40</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res40</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res41</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExists</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res41</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res42</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res42</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res43</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res43</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res44</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res44</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res45</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExists</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res45</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res46</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyDelete</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res46</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res47</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLength</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res47</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res48</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res48</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; Null</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res49</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res49</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">2</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res50</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res50</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:5, bike:4, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_list_tutorial-stepltrim.1')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_list_tutorial-stepltrim.1" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/ListTutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <p> </p> </li> </ul> <h3 id="what-are-lists"> What are Lists? </h3> <p> To explain the List data type it's better to start with a little bit of theory, as the term <em> List </em> is often used in an improper way by information technology folks. For instance "Python Lists" are not what the name may suggest (Linked Lists), but rather Arrays (the same data type is called Array in Ruby actually). </p> <p> From a very general point of view a List is just a sequence of ordered elements: 10,20,1,2,3 is a list. But the properties of a List implemented using an Array are very different from the properties of a List implemented using a <em> Linked List </em> . </p> <p> Redis lists are implemented via Linked Lists. This means that even if you have millions of elements inside a list, the operation of adding a new element in the head or in the tail of the list is performed <em> in constant time </em> . The speed of adding a new element with the <a href="/docs/latest/commands/lpush/"> <code> LPUSH </code> </a> command to the head of a list with ten elements is the same as adding an element to the head of list with 10 million elements. </p> <p> What's the downside? Accessing an element <em> by index </em> is very fast in lists implemented with an Array (constant time indexed access) and not so fast in lists implemented by linked lists (where the operation requires an amount of work proportional to the index of the accessed element). </p> <p> Redis Lists are implemented with linked lists because for a database system it is crucial to be able to add elements to a very long list in a very fast way. Another strong advantage, as you'll see in a moment, is that Redis Lists can be taken at constant length in constant time. </p> <p> When fast access to the middle of a large collection of elements is important, there is a different data structure that can be used, called sorted sets. Sorted sets are covered in the <a href="/docs/latest/develop/data-types/sorted-sets/"> Sorted sets </a> tutorial page. </p> <h3 id="first-steps-with-redis-lists"> First steps with Redis Lists </h3> <p> The <a href="/docs/latest/commands/lpush/"> <code> LPUSH </code> </a> command adds a new element into a list, on the left (at the head), while the <a href="/docs/latest/commands/rpush/"> <code> RPUSH </code> </a> command adds a new element into a list, on the right (at the tail). Finally the <a href="/docs/latest/commands/lrange/"> <code> LRANGE </code> </a> command extracts ranges of elements from lists: </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="list_tutorial-steplpush_rpush"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_list_tutorial-steplpush_rpush" name="list_tutorial-steplpush_rpush" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_list_tutorial-steplpush_rpush" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-list_tutorial-steplpush_rpush" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_list_tutorial-steplpush_rpush" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; RPUSH bikes:repairs bike:1 </span></span><span class="line hl"><span class="cl">(integer) 1 </span></span><span class="line hl"><span class="cl">&gt; RPUSH bikes:repairs bike:2 </span></span><span class="line hl"><span class="cl">(integer) 2 </span></span><span class="line hl"><span class="cl">&gt; LPUSH bikes:repairs bike:important_bike </span></span><span class="line hl"><span class="cl">(integer) 3 </span></span><span class="line hl"><span class="cl">&gt; LRANGE bikes:repairs 0 -1 </span></span><span class="line hl"><span class="cl">1) "bike:important_bike" </span></span><span class="line hl"><span class="cl">2) "bike:1" </span></span><span class="line hl"><span class="cl">3) "bike:2"</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_list_tutorial-steplpush_rpush')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_list_tutorial-steplpush_rpush" name="list_tutorial-steplpush_rpush" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_list_tutorial-steplpush_rpush" title="Open example"> Python </label> <div aria-labelledby="tab-list_tutorial-steplpush_rpush" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_list_tutorial-steplpush_rpush" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for List doc pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/lists/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">llen</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lmove</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bikes:finished"</span><span class="p">,</span> <span class="s2">"LEFT"</span><span class="p">,</span> <span class="s2">"LEFT"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:1']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:finished"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:2']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:important_bike"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res18</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:important_bike', 'bike:1', 'bike:2']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:important_bike"</span><span class="p">,</span> <span class="s2">"bike:very_important_bike"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="n">res21</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:very_important_bike', 'bike:important_bike', 'bike:1', ...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res22</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res22</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res23</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res23</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:3'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res24</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res24</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:1'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res25</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res25</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res26</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res26</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res28</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res28</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res29</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res29</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:5', 'bike:4', 'bike:3']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res28</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res28</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res29</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res29</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:3', 'bike:4', 'bike:5']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res31</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res31</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res32</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res32</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ('bikes:repairs', 'bike:2')</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res33</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res33</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ('bikes:repairs', 'bike:1')</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res34</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res34</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res35</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res35</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res36</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res36</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res37</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res37</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res38</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">type</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res38</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'string'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">try</span><span class="p">:</span> </span></span><span class="line"><span class="cl"> <span class="n">res39</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1"># &gt;&gt;&gt; redis.exceptions.ResponseError:</span> </span></span><span class="line"><span class="cl"> <span class="c1"># &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value</span> </span></span><span class="line"><span class="cl"><span class="k">except</span> <span class="n">redis</span><span class="o">.</span><span class="n">exceptions</span><span class="o">.</span><span class="n">ResponseError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> </span></span><span class="line"><span class="cl"> <span class="nb">print</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res36</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res40</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res40</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res41</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res41</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:3'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res42</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res42</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res43</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res43</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:1'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res44</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res44</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res45</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res45</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res46</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">llen</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res46</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res47</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res47</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res48</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res48</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res49</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res49</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res50</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res50</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:5', 'bike:4', 'bike:3']</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_list_tutorial-steplpush_rpush')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_list_tutorial-steplpush_rpush" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_list.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_list_tutorial-steplpush_rpush" name="list_tutorial-steplpush_rpush" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_list_tutorial-steplpush_rpush" title="Open example"> Node.js </label> <div aria-labelledby="tab-list_tutorial-steplpush_rpush" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_list_tutorial-steplpush_rpush" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">createClient</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">);</span> <span class="c1">// bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">);</span> <span class="c1">// bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">);</span> <span class="c1">// bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">);</span> <span class="c1">// bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lLen</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lMove</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bikes:finished'</span><span class="p">,</span> <span class="s1">'LEFT'</span><span class="p">,</span> <span class="s1">'LEFT'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res13</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res13</span><span class="p">);</span> <span class="c1">// ['bike:1'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:finished'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res14</span><span class="p">);</span> <span class="c1">// ['bike:2'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res15</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res15</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res16</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res16</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res17</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:important_bike'</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res17</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res18</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res18</span><span class="p">);</span> <span class="c1">// ['bike:important_bike', 'bike:1', 'bike:2'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res19</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:important_bike'</span><span class="p">,</span> <span class="s1">'bike:very_important_bike'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res20</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res21</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res21</span><span class="p">);</span> <span class="c1">// ['bike:very_important_bike', 'bike:important_bike', 'bike:1', 'bike:2', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res22</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res22</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res23</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res23</span><span class="p">);</span> <span class="c1">// 'bike:3' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res24</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res24</span><span class="p">);</span> <span class="c1">// 'bike:1' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res25</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res25</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res26</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res26</span><span class="p">);</span> <span class="c1">// None </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res27</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res28</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res29</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29</span><span class="p">);</span> <span class="c1">// ['bike:5', 'bike:4', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res27eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27eol</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res28eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28eol</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res29eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29eol</span><span class="p">);</span> <span class="c1">// ['bike:3', 'bike:4', 'bike:5'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res31</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res31</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res32</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res32</span><span class="p">);</span> <span class="c1">// { key: 'bikes:repairs', element: 'bike:2' } </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res33</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res33</span><span class="p">);</span> <span class="c1">// { key: 'bikes:repairs', element: 'bike:1' } </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res34</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res34</span><span class="p">);</span> <span class="c1">// null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res35</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res35</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res36</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res37</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res38</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">type</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res38</span><span class="p">);</span> <span class="c1">// 'string' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="k">try</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kr">const</span> <span class="nx">res39</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// redis.exceptions.ResponseError: </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ErrorReply: WRONGTYPE Operation against a key holding the wrong kind of value] </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="k">catch</span><span class="p">(</span><span class="nx">e</span><span class="p">){</span> </span></span><span class="line"><span class="cl"> <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">e</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res40</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">exists</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res40</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res41</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res41</span><span class="p">);</span> <span class="c1">// 'bike:3' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res42</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res42</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res43</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res43</span><span class="p">);</span> <span class="c1">// 'bike:1' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res44</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">exists</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res44</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res45</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res45</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res46</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lLen</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res46</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res47</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res47</span><span class="p">);</span> <span class="c1">// null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res48</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res48</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res49</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res49</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res50</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res50</span><span class="p">);</span> <span class="c1">// ['bike:5', 'bike:4', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_list_tutorial-steplpush_rpush')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_list_tutorial-steplpush_rpush" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-list.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_list_tutorial-steplpush_rpush" name="list_tutorial-steplpush_rpush" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_list_tutorial-steplpush_rpush" title="Open example"> Java </label> <div aria-labelledby="tab-list_tutorial-steplpush_rpush" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_list_tutorial-steplpush_rpush" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nn">io.redis.examples</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.junit.Test</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.args.ListDirection</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.List</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.*</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">ListExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">llen</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lmove</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bikes:finished"</span><span class="o">,</span> <span class="n">ListDirection</span><span class="o">.</span><span class="na">LEFT</span><span class="o">,</span> <span class="n">ListDirection</span><span class="o">.</span><span class="na">LEFT</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res13</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:finished"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res14</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res15</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res16</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res16</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:important_bike"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res17</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:important_bike, bike:1, bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res19</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:important_bike"</span><span class="o">,</span> <span class="s">"bike:very_important_bike"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res20</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res21</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res21</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:very_important_bike, bike:important_bike, bike:1, bike:2, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res22</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res22</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res23</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res23</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res24</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res24</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res25</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res25</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res26</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res26</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="mi">2</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res28</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:5, bike:4, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="o">-</span><span class="mi">3</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:3, bike:4, bike:5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res31</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res31</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res32</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span> <span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res32</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; (bikes:repairs, bike:2) </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res33</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res33</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; (bikes:repairs, bike:1) </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res34</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res34</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res35</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">del</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res35</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res36</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res37</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res37</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res38</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">type</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res38</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; string </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="k">try</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res39</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> <span class="k">catch</span> <span class="o">(</span><span class="n">Exception</span> <span class="n">e</span><span class="o">)</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">e</span><span class="o">.</span><span class="na">printStackTrace</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; redis.clients.jedis.exceptions.JedisDataException: </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="o">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res40</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">exists</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res40</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res41</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res41</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res42</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res42</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res43</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res43</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res44</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">exists</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res44</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res45</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">del</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res45</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res46</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">llen</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res46</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res47</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res47</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res48</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res48</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res49</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="mi">2</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res49</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res50</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res50</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:5, bike:4, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_list_tutorial-steplpush_rpush')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_list_tutorial-steplpush_rpush" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/ListExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_list_tutorial-steplpush_rpush" name="list_tutorial-steplpush_rpush" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_list_tutorial-steplpush_rpush" title="Open example"> Go </label> <div aria-labelledby="tab-list_tutorial-steplpush_rpush" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_list_tutorial-steplpush_rpush" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_queue</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_stack</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_llen</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lmove_lrange</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LMove</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bikes:finished"</span><span class="p">,</span> <span class="s">"LEFT"</span><span class="p">,</span> <span class="s">"LEFT"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:finished"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lpush_rpush</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:important_bike bike:1 bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_variadic</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">,</span> <span class="s">"bike:very_important_bike"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:very_important_bike bike:important_bike bike:1 bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lpop_rpop</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res22</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res23</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res23</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res24</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res24</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res25</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res25</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res26</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res26</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;empty string&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res27</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res27</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res28</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res28</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res29</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res29</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:5 bike:4 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim_end_of_list</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res30</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res30</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res31</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res31</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res32</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res32</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:3 bike:4 bike:5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_brpop</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res33</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res33</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res34</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res34</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bikes:repairs bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res35</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res35</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bikes:repairs bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res36</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res36</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res37</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Del</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res37</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res38</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res38</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule11</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res39</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res39</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res40</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Type</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res40</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; string </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res41</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res41</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res42</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res42</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res43</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Exists</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res43</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res44</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res44</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res45</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res45</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res46</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res46</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res47</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Exists</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res47</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule3</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res48</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Del</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res48</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res49</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res49</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res50</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res50</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;empty string&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res51</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res51</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res52</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res52</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res53</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res53</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:5 bike:4 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_list_tutorial-steplpush_rpush')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_list_tutorial-steplpush_rpush" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/list_tutorial_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_list_tutorial-steplpush_rpush" name="list_tutorial-steplpush_rpush" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_list_tutorial-steplpush_rpush" title="Open example"> C# </label> <div aria-labelledby="tab-list_tutorial-steplpush_rpush" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_list_tutorial-steplpush_rpush" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">ListExample</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res3</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res4</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res5</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res7</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res8</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLength</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res10</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListMove</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"{bikes}:finished"</span><span class="p">,</span> <span class="n">ListSide</span><span class="p">.</span><span class="n">Left</span><span class="p">,</span> <span class="n">ListSide</span><span class="p">.</span><span class="n">Left</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">Write</span><span class="p">(</span><span class="n">res12</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res13</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"{bikes}:finished"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res14</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res15</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res16</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res17</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res18</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:important_bike, bike:1, bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res19</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:important_bike"</span><span class="p">,</span> <span class="s">"bike:very_important_bike"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res20</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res21</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res21</span><span class="p">));</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; "bike:very_important_bike, bike:important_bike, bike:1, bike:2, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res22</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res22</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res23</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res23</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res24</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res24</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res25</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res25</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res26</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res26</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; &lt;Empty string&gt;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res27</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res27</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res28</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res28</span><span class="p">));</span> <span class="c1">// "bike:5, bike:4, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res29</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res29</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="p">-</span><span class="m">3</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res30</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res30</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:3, bike:4, bike:5"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res31</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res31</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res32</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="p">(</span><span class="n">res32</span> <span class="p">!=</span> <span class="k">null</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"{res32.Item1} -&gt; {res32.Item2}"</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bikes:repairs -&gt; bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res33</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="p">(</span><span class="n">res33</span> <span class="p">!=</span> <span class="k">null</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"{res33.Item1} -&gt; {res33.Item2}"</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bikes:repairs -&gt; bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res34</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res34</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "Null"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res35</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyDelete</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res35</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res36</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res36</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res37</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res37</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisType</span> <span class="n">res38</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyType</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res38</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; RedisType.String</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">try</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res39</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="k">catch</span> <span class="p">(</span><span class="n">Exception</span> <span class="n">e</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">e</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res40</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res40</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res41</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExists</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res41</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res42</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res42</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res43</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res43</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res44</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res44</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res45</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExists</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res45</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res46</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyDelete</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res46</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res47</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLength</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res47</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res48</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res48</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; Null</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res49</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res49</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res50</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res50</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:5, bike:4, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_list_tutorial-steplpush_rpush')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_list_tutorial-steplpush_rpush" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/ListTutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <p> Note that <a href="/docs/latest/commands/lrange/"> <code> LRANGE </code> </a> takes two indexes, the first and the last element of the range to return. Both the indexes can be negative, telling Redis to start counting from the end: so -1 is the last element, -2 is the penultimate element of the list, and so forth. </p> <p> As you can see <a href="/docs/latest/commands/rpush/"> <code> RPUSH </code> </a> appended the elements on the right of the list, while the final <a href="/docs/latest/commands/lpush/"> <code> LPUSH </code> </a> appended the element on the left. </p> <p> Both commands are <em> variadic commands </em> , meaning that you are free to push multiple elements into a list in a single call: </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="list_tutorial-stepvariadic"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_list_tutorial-stepvariadic" name="list_tutorial-stepvariadic" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_list_tutorial-stepvariadic" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-list_tutorial-stepvariadic" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_list_tutorial-stepvariadic" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; RPUSH bikes:repairs bike:1 bike:2 bike:3 </span></span><span class="line hl"><span class="cl">(integer) 3 </span></span><span class="line hl"><span class="cl">&gt; LPUSH bikes:repairs bike:important_bike bike:very_important_bike </span></span><span class="line hl"><span class="cl">&gt; LRANGE mylist 0 -1 </span></span><span class="line hl"><span class="cl">1) "bike:very_important_bike" </span></span><span class="line hl"><span class="cl">2) "bike:important_bike" </span></span><span class="line hl"><span class="cl">3) "bike:1" </span></span><span class="line hl"><span class="cl">4) "bike:2" </span></span><span class="line hl"><span class="cl">5) "bike:3"</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_list_tutorial-stepvariadic')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_list_tutorial-stepvariadic" name="list_tutorial-stepvariadic" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_list_tutorial-stepvariadic" title="Open example"> Python </label> <div aria-labelledby="tab-list_tutorial-stepvariadic" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_list_tutorial-stepvariadic" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for List doc pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/lists/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">llen</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lmove</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bikes:finished"</span><span class="p">,</span> <span class="s2">"LEFT"</span><span class="p">,</span> <span class="s2">"LEFT"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:1']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:finished"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:2']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:important_bike"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res18</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:important_bike', 'bike:1', 'bike:2']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:important_bike"</span><span class="p">,</span> <span class="s2">"bike:very_important_bike"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span> </span></span><span class="line hl"><span class="cl"> <span class="n">res21</span> </span></span><span class="line hl"><span class="cl"><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:very_important_bike', 'bike:important_bike', 'bike:1', ...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res22</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res22</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res23</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res23</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:3'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res24</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res24</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:1'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res25</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res25</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res26</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res26</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res28</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res28</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res29</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res29</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:5', 'bike:4', 'bike:3']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res28</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res28</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res29</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res29</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:3', 'bike:4', 'bike:5']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res31</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res31</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res32</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res32</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ('bikes:repairs', 'bike:2')</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res33</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res33</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ('bikes:repairs', 'bike:1')</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res34</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res34</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res35</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res35</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res36</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res36</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res37</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res37</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res38</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">type</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res38</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'string'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">try</span><span class="p">:</span> </span></span><span class="line"><span class="cl"> <span class="n">res39</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1"># &gt;&gt;&gt; redis.exceptions.ResponseError:</span> </span></span><span class="line"><span class="cl"> <span class="c1"># &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value</span> </span></span><span class="line"><span class="cl"><span class="k">except</span> <span class="n">redis</span><span class="o">.</span><span class="n">exceptions</span><span class="o">.</span><span class="n">ResponseError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> </span></span><span class="line"><span class="cl"> <span class="nb">print</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res36</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res40</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res40</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res41</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res41</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:3'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res42</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res42</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res43</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res43</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:1'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res44</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res44</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res45</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res45</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res46</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">llen</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res46</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res47</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res47</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res48</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res48</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res49</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res49</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res50</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res50</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:5', 'bike:4', 'bike:3']</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_list_tutorial-stepvariadic')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_list_tutorial-stepvariadic" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_list.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_list_tutorial-stepvariadic" name="list_tutorial-stepvariadic" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_list_tutorial-stepvariadic" title="Open example"> Node.js </label> <div aria-labelledby="tab-list_tutorial-stepvariadic" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_list_tutorial-stepvariadic" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">createClient</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">);</span> <span class="c1">// bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">);</span> <span class="c1">// bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">);</span> <span class="c1">// bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">);</span> <span class="c1">// bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lLen</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lMove</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bikes:finished'</span><span class="p">,</span> <span class="s1">'LEFT'</span><span class="p">,</span> <span class="s1">'LEFT'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res13</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res13</span><span class="p">);</span> <span class="c1">// ['bike:1'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:finished'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res14</span><span class="p">);</span> <span class="c1">// ['bike:2'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res15</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res15</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res16</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res16</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res17</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:important_bike'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res17</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res18</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res18</span><span class="p">);</span> <span class="c1">// ['bike:important_bike', 'bike:1', 'bike:2'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res19</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line hl"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:important_bike'</span><span class="p">,</span> <span class="s1">'bike:very_important_bike'</span><span class="p">]</span> </span></span><span class="line hl"><span class="cl"><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res20</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res21</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res21</span><span class="p">);</span> <span class="c1">// ['bike:very_important_bike', 'bike:important_bike', 'bike:1', 'bike:2', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res22</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res22</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res23</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res23</span><span class="p">);</span> <span class="c1">// 'bike:3' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res24</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res24</span><span class="p">);</span> <span class="c1">// 'bike:1' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res25</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res25</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res26</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res26</span><span class="p">);</span> <span class="c1">// None </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res27</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res28</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res29</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29</span><span class="p">);</span> <span class="c1">// ['bike:5', 'bike:4', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res27eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27eol</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res28eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28eol</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res29eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29eol</span><span class="p">);</span> <span class="c1">// ['bike:3', 'bike:4', 'bike:5'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res31</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res31</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res32</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res32</span><span class="p">);</span> <span class="c1">// { key: 'bikes:repairs', element: 'bike:2' } </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res33</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res33</span><span class="p">);</span> <span class="c1">// { key: 'bikes:repairs', element: 'bike:1' } </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res34</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res34</span><span class="p">);</span> <span class="c1">// null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res35</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res35</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res36</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res37</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res38</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">type</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res38</span><span class="p">);</span> <span class="c1">// 'string' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="k">try</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kr">const</span> <span class="nx">res39</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// redis.exceptions.ResponseError: </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ErrorReply: WRONGTYPE Operation against a key holding the wrong kind of value] </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="k">catch</span><span class="p">(</span><span class="nx">e</span><span class="p">){</span> </span></span><span class="line"><span class="cl"> <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">e</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res40</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">exists</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res40</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res41</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res41</span><span class="p">);</span> <span class="c1">// 'bike:3' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res42</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res42</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res43</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res43</span><span class="p">);</span> <span class="c1">// 'bike:1' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res44</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">exists</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res44</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res45</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res45</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res46</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lLen</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res46</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res47</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res47</span><span class="p">);</span> <span class="c1">// null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res48</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res48</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res49</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res49</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res50</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res50</span><span class="p">);</span> <span class="c1">// ['bike:5', 'bike:4', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_list_tutorial-stepvariadic')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_list_tutorial-stepvariadic" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-list.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_list_tutorial-stepvariadic" name="list_tutorial-stepvariadic" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_list_tutorial-stepvariadic" title="Open example"> Java </label> <div aria-labelledby="tab-list_tutorial-stepvariadic" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_list_tutorial-stepvariadic" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nn">io.redis.examples</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.junit.Test</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.args.ListDirection</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.List</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.*</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">ListExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">llen</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lmove</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bikes:finished"</span><span class="o">,</span> <span class="n">ListDirection</span><span class="o">.</span><span class="na">LEFT</span><span class="o">,</span> <span class="n">ListDirection</span><span class="o">.</span><span class="na">LEFT</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res13</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:finished"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res14</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res15</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res16</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res16</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:important_bike"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res17</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:important_bike, bike:1, bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res19</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:important_bike"</span><span class="o">,</span> <span class="s">"bike:very_important_bike"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res20</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res21</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res21</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:very_important_bike, bike:important_bike, bike:1, bike:2, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res22</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res22</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res23</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res23</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res24</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res24</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res25</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res25</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res26</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res26</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="mi">2</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res28</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:5, bike:4, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="o">-</span><span class="mi">3</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:3, bike:4, bike:5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res31</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res31</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res32</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span> <span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res32</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; (bikes:repairs, bike:2) </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res33</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res33</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; (bikes:repairs, bike:1) </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res34</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res34</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res35</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">del</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res35</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res36</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res37</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res37</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res38</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">type</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res38</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; string </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="k">try</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res39</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> <span class="k">catch</span> <span class="o">(</span><span class="n">Exception</span> <span class="n">e</span><span class="o">)</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">e</span><span class="o">.</span><span class="na">printStackTrace</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; redis.clients.jedis.exceptions.JedisDataException: </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="o">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res40</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">exists</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res40</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res41</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res41</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res42</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res42</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res43</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res43</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res44</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">exists</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res44</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res45</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">del</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res45</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res46</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">llen</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res46</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res47</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res47</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res48</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res48</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res49</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="mi">2</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res49</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res50</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res50</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:5, bike:4, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_list_tutorial-stepvariadic')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_list_tutorial-stepvariadic" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/ListExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_list_tutorial-stepvariadic" name="list_tutorial-stepvariadic" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_list_tutorial-stepvariadic" title="Open example"> Go </label> <div aria-labelledby="tab-list_tutorial-stepvariadic" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_list_tutorial-stepvariadic" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_queue</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_stack</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_llen</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lmove_lrange</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LMove</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bikes:finished"</span><span class="p">,</span> <span class="s">"LEFT"</span><span class="p">,</span> <span class="s">"LEFT"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:finished"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lpush_rpush</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:important_bike bike:1 bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_variadic</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">,</span> <span class="s">"bike:very_important_bike"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:very_important_bike bike:important_bike bike:1 bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lpop_rpop</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res22</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res23</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res23</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res24</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res24</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res25</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res25</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res26</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res26</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;empty string&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res27</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res27</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res28</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res28</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res29</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res29</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:5 bike:4 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim_end_of_list</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res30</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res30</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res31</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res31</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res32</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res32</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:3 bike:4 bike:5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_brpop</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res33</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res33</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res34</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res34</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bikes:repairs bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res35</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res35</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bikes:repairs bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res36</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res36</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res37</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Del</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res37</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res38</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res38</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule11</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res39</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res39</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res40</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Type</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res40</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; string </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res41</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res41</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res42</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res42</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res43</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Exists</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res43</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res44</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res44</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res45</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res45</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res46</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res46</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res47</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Exists</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res47</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule3</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res48</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Del</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res48</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res49</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res49</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res50</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res50</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;empty string&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res51</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res51</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res52</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res52</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res53</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res53</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:5 bike:4 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_list_tutorial-stepvariadic')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_list_tutorial-stepvariadic" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/list_tutorial_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_list_tutorial-stepvariadic" name="list_tutorial-stepvariadic" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_list_tutorial-stepvariadic" title="Open example"> C# </label> <div aria-labelledby="tab-list_tutorial-stepvariadic" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_list_tutorial-stepvariadic" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">ListExample</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res3</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res4</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res5</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res7</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res8</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLength</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res10</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListMove</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"{bikes}:finished"</span><span class="p">,</span> <span class="n">ListSide</span><span class="p">.</span><span class="n">Left</span><span class="p">,</span> <span class="n">ListSide</span><span class="p">.</span><span class="n">Left</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">Write</span><span class="p">(</span><span class="n">res12</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res13</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"{bikes}:finished"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res14</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res15</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res16</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res17</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res18</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:important_bike, bike:1, bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res19</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:important_bike"</span><span class="p">,</span> <span class="s">"bike:very_important_bike"</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res20</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res21</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res21</span><span class="p">));</span> </span></span><span class="line hl"><span class="cl"> <span class="c1">// &gt;&gt;&gt; "bike:very_important_bike, bike:important_bike, bike:1, bike:2, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res22</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res22</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res23</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res23</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res24</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res24</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res25</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res25</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res26</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res26</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; &lt;Empty string&gt;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res27</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res27</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res28</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res28</span><span class="p">));</span> <span class="c1">// "bike:5, bike:4, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res29</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res29</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="p">-</span><span class="m">3</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res30</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res30</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:3, bike:4, bike:5"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res31</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res31</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res32</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="p">(</span><span class="n">res32</span> <span class="p">!=</span> <span class="k">null</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"{res32.Item1} -&gt; {res32.Item2}"</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bikes:repairs -&gt; bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res33</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="p">(</span><span class="n">res33</span> <span class="p">!=</span> <span class="k">null</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"{res33.Item1} -&gt; {res33.Item2}"</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bikes:repairs -&gt; bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res34</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res34</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "Null"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res35</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyDelete</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res35</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res36</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res36</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res37</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res37</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisType</span> <span class="n">res38</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyType</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res38</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; RedisType.String</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">try</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res39</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="k">catch</span> <span class="p">(</span><span class="n">Exception</span> <span class="n">e</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">e</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res40</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res40</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res41</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExists</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res41</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res42</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res42</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res43</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res43</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res44</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res44</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res45</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExists</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res45</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res46</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyDelete</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res46</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res47</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLength</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res47</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res48</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res48</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; Null</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res49</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res49</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res50</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res50</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:5, bike:4, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_list_tutorial-stepvariadic')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_list_tutorial-stepvariadic" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/ListTutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <p> An important operation defined on Redis lists is the ability to <em> pop elements </em> . Popping elements is the operation of both retrieving the element from the list, and eliminating it from the list, at the same time. You can pop elements from left and right, similarly to how you can push elements in both sides of the list. We'll add three elements and pop three elements, so at the end of this sequence of commands the list is empty and there are no more elements to pop: </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="list_tutorial-steplpop_rpop"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_list_tutorial-steplpop_rpop" name="list_tutorial-steplpop_rpop" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_list_tutorial-steplpop_rpop" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-list_tutorial-steplpop_rpop" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_list_tutorial-steplpop_rpop" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; RPUSH bikes:repairs bike:1 bike:2 bike:3 </span></span><span class="line hl"><span class="cl">(integer) 3 </span></span><span class="line hl"><span class="cl">&gt; RPOP bikes:repairs </span></span><span class="line hl"><span class="cl">"bike:3" </span></span><span class="line hl"><span class="cl">&gt; LPOP bikes:repairs </span></span><span class="line hl"><span class="cl">"bike:1" </span></span><span class="line hl"><span class="cl">&gt; RPOP bikes:repairs </span></span><span class="line hl"><span class="cl">"bike:2" </span></span><span class="line hl"><span class="cl">&gt; RPOP bikes:repairs </span></span><span class="line hl"><span class="cl">(nil)</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_list_tutorial-steplpop_rpop')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_list_tutorial-steplpop_rpop" name="list_tutorial-steplpop_rpop" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_list_tutorial-steplpop_rpop" title="Open example"> Python </label> <div aria-labelledby="tab-list_tutorial-steplpop_rpop" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_list_tutorial-steplpop_rpop" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for List doc pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/lists/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">llen</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lmove</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bikes:finished"</span><span class="p">,</span> <span class="s2">"LEFT"</span><span class="p">,</span> <span class="s2">"LEFT"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:1']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:finished"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:2']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:important_bike"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res18</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:important_bike', 'bike:1', 'bike:2']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:important_bike"</span><span class="p">,</span> <span class="s2">"bike:very_important_bike"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="n">res21</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:very_important_bike', 'bike:important_bike', 'bike:1', ...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res22</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res22</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res23</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res23</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:3'</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res24</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res24</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:1'</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res25</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res25</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res26</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res26</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res28</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res28</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res29</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res29</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:5', 'bike:4', 'bike:3']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res28</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res28</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res29</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res29</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:3', 'bike:4', 'bike:5']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res31</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res31</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res32</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res32</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ('bikes:repairs', 'bike:2')</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res33</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res33</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ('bikes:repairs', 'bike:1')</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res34</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res34</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res35</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res35</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res36</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res36</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res37</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res37</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res38</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">type</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res38</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'string'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">try</span><span class="p">:</span> </span></span><span class="line"><span class="cl"> <span class="n">res39</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1"># &gt;&gt;&gt; redis.exceptions.ResponseError:</span> </span></span><span class="line"><span class="cl"> <span class="c1"># &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value</span> </span></span><span class="line"><span class="cl"><span class="k">except</span> <span class="n">redis</span><span class="o">.</span><span class="n">exceptions</span><span class="o">.</span><span class="n">ResponseError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> </span></span><span class="line"><span class="cl"> <span class="nb">print</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res36</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res40</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res40</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res41</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res41</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:3'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res42</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res42</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res43</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res43</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:1'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res44</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res44</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res45</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res45</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res46</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">llen</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res46</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res47</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res47</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res48</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res48</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res49</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res49</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res50</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res50</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:5', 'bike:4', 'bike:3']</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_list_tutorial-steplpop_rpop')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_list_tutorial-steplpop_rpop" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_list.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_list_tutorial-steplpop_rpop" name="list_tutorial-steplpop_rpop" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_list_tutorial-steplpop_rpop" title="Open example"> Node.js </label> <div aria-labelledby="tab-list_tutorial-steplpop_rpop" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_list_tutorial-steplpop_rpop" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">createClient</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">);</span> <span class="c1">// bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">);</span> <span class="c1">// bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">);</span> <span class="c1">// bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">);</span> <span class="c1">// bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lLen</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lMove</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bikes:finished'</span><span class="p">,</span> <span class="s1">'LEFT'</span><span class="p">,</span> <span class="s1">'LEFT'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res13</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res13</span><span class="p">);</span> <span class="c1">// ['bike:1'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:finished'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res14</span><span class="p">);</span> <span class="c1">// ['bike:2'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res15</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res15</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res16</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res16</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res17</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:important_bike'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res17</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res18</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res18</span><span class="p">);</span> <span class="c1">// ['bike:important_bike', 'bike:1', 'bike:2'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res19</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:important_bike'</span><span class="p">,</span> <span class="s1">'bike:very_important_bike'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res20</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res21</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res21</span><span class="p">);</span> <span class="c1">// ['bike:very_important_bike', 'bike:important_bike', 'bike:1', 'bike:2', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res22</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res22</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res23</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res23</span><span class="p">);</span> <span class="c1">// 'bike:3' </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res24</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res24</span><span class="p">);</span> <span class="c1">// 'bike:1' </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res25</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res25</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res26</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res26</span><span class="p">);</span> <span class="c1">// None </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res27</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res28</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res29</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29</span><span class="p">);</span> <span class="c1">// ['bike:5', 'bike:4', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res27eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27eol</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res28eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28eol</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res29eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29eol</span><span class="p">);</span> <span class="c1">// ['bike:3', 'bike:4', 'bike:5'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res31</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res31</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res32</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res32</span><span class="p">);</span> <span class="c1">// { key: 'bikes:repairs', element: 'bike:2' } </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res33</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res33</span><span class="p">);</span> <span class="c1">// { key: 'bikes:repairs', element: 'bike:1' } </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res34</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res34</span><span class="p">);</span> <span class="c1">// null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res35</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res35</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res36</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res37</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res38</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">type</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res38</span><span class="p">);</span> <span class="c1">// 'string' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="k">try</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kr">const</span> <span class="nx">res39</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// redis.exceptions.ResponseError: </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ErrorReply: WRONGTYPE Operation against a key holding the wrong kind of value] </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="k">catch</span><span class="p">(</span><span class="nx">e</span><span class="p">){</span> </span></span><span class="line"><span class="cl"> <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">e</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res40</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">exists</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res40</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res41</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res41</span><span class="p">);</span> <span class="c1">// 'bike:3' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res42</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res42</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res43</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res43</span><span class="p">);</span> <span class="c1">// 'bike:1' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res44</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">exists</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res44</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res45</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res45</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res46</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lLen</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res46</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res47</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res47</span><span class="p">);</span> <span class="c1">// null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res48</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res48</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res49</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res49</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res50</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res50</span><span class="p">);</span> <span class="c1">// ['bike:5', 'bike:4', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_list_tutorial-steplpop_rpop')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_list_tutorial-steplpop_rpop" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-list.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_list_tutorial-steplpop_rpop" name="list_tutorial-steplpop_rpop" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_list_tutorial-steplpop_rpop" title="Open example"> Java </label> <div aria-labelledby="tab-list_tutorial-steplpop_rpop" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_list_tutorial-steplpop_rpop" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nn">io.redis.examples</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.junit.Test</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.args.ListDirection</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.List</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.*</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">ListExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">llen</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lmove</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bikes:finished"</span><span class="o">,</span> <span class="n">ListDirection</span><span class="o">.</span><span class="na">LEFT</span><span class="o">,</span> <span class="n">ListDirection</span><span class="o">.</span><span class="na">LEFT</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res13</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:finished"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res14</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res15</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res16</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res16</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:important_bike"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res17</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:important_bike, bike:1, bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res19</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:important_bike"</span><span class="o">,</span> <span class="s">"bike:very_important_bike"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res20</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res21</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res21</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:very_important_bike, bike:important_bike, bike:1, bike:2, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res22</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res22</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">res23</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res23</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">res24</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res24</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">res25</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res25</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">res26</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res26</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="mi">2</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res28</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:5, bike:4, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="o">-</span><span class="mi">3</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:3, bike:4, bike:5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res31</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res31</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res32</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span> <span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res32</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; (bikes:repairs, bike:2) </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res33</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res33</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; (bikes:repairs, bike:1) </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res34</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res34</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res35</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">del</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res35</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res36</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res37</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res37</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res38</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">type</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res38</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; string </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="k">try</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res39</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> <span class="k">catch</span> <span class="o">(</span><span class="n">Exception</span> <span class="n">e</span><span class="o">)</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">e</span><span class="o">.</span><span class="na">printStackTrace</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; redis.clients.jedis.exceptions.JedisDataException: </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="o">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res40</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">exists</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res40</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res41</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res41</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res42</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res42</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res43</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res43</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res44</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">exists</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res44</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res45</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">del</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res45</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res46</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">llen</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res46</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res47</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res47</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res48</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res48</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res49</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="mi">2</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res49</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res50</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res50</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:5, bike:4, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_list_tutorial-steplpop_rpop')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_list_tutorial-steplpop_rpop" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/ListExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_list_tutorial-steplpop_rpop" name="list_tutorial-steplpop_rpop" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_list_tutorial-steplpop_rpop" title="Open example"> Go </label> <div aria-labelledby="tab-list_tutorial-steplpop_rpop" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_list_tutorial-steplpop_rpop" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_queue</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_stack</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_llen</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lmove_lrange</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LMove</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bikes:finished"</span><span class="p">,</span> <span class="s">"LEFT"</span><span class="p">,</span> <span class="s">"LEFT"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:finished"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lpush_rpush</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:important_bike bike:1 bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_variadic</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">,</span> <span class="s">"bike:very_important_bike"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:very_important_bike bike:important_bike bike:1 bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lpop_rpop</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res22</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res23</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res23</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res24</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res24</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res25</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res25</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res26</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res26</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;empty string&gt; </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res27</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res27</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res28</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res28</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res29</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res29</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:5 bike:4 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim_end_of_list</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res30</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res30</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res31</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res31</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res32</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res32</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:3 bike:4 bike:5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_brpop</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res33</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res33</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res34</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res34</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bikes:repairs bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res35</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res35</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bikes:repairs bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res36</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res36</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res37</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Del</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res37</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res38</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res38</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule11</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res39</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res39</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res40</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Type</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res40</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; string </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res41</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res41</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res42</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res42</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res43</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Exists</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res43</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res44</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res44</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res45</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res45</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res46</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res46</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res47</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Exists</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res47</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule3</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res48</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Del</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res48</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res49</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res49</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res50</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res50</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;empty string&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res51</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res51</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res52</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res52</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res53</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res53</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:5 bike:4 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_list_tutorial-steplpop_rpop')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_list_tutorial-steplpop_rpop" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/list_tutorial_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_list_tutorial-steplpop_rpop" name="list_tutorial-steplpop_rpop" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_list_tutorial-steplpop_rpop" title="Open example"> C# </label> <div aria-labelledby="tab-list_tutorial-steplpop_rpop" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_list_tutorial-steplpop_rpop" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">ListExample</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res3</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res4</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res5</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res7</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res8</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLength</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res10</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListMove</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"{bikes}:finished"</span><span class="p">,</span> <span class="n">ListSide</span><span class="p">.</span><span class="n">Left</span><span class="p">,</span> <span class="n">ListSide</span><span class="p">.</span><span class="n">Left</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">Write</span><span class="p">(</span><span class="n">res12</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res13</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"{bikes}:finished"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res14</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res15</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res16</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res17</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res18</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:important_bike, bike:1, bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res19</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:important_bike"</span><span class="p">,</span> <span class="s">"bike:very_important_bike"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res20</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res21</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res21</span><span class="p">));</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; "bike:very_important_bike, bike:important_bike, bike:1, bike:2, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res22</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res22</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res23</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res23</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:3"</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res24</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res24</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res25</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res25</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res26</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res26</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; &lt;Empty string&gt;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res27</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res27</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res28</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res28</span><span class="p">));</span> <span class="c1">// "bike:5, bike:4, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res29</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res29</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="p">-</span><span class="m">3</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res30</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res30</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:3, bike:4, bike:5"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res31</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res31</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res32</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="p">(</span><span class="n">res32</span> <span class="p">!=</span> <span class="k">null</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"{res32.Item1} -&gt; {res32.Item2}"</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bikes:repairs -&gt; bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res33</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="p">(</span><span class="n">res33</span> <span class="p">!=</span> <span class="k">null</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"{res33.Item1} -&gt; {res33.Item2}"</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bikes:repairs -&gt; bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res34</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res34</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "Null"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res35</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyDelete</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res35</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res36</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res36</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res37</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res37</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisType</span> <span class="n">res38</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyType</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res38</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; RedisType.String</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">try</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res39</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="k">catch</span> <span class="p">(</span><span class="n">Exception</span> <span class="n">e</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">e</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res40</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res40</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res41</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExists</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res41</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res42</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res42</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res43</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res43</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res44</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res44</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res45</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExists</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res45</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res46</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyDelete</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res46</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res47</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLength</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res47</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res48</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res48</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; Null</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res49</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res49</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res50</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res50</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:5, bike:4, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_list_tutorial-steplpop_rpop')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_list_tutorial-steplpop_rpop" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/ListTutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <p> Redis returned a NULL value to signal that there are no elements in the list. </p> <h3 id="common-use-cases-for-lists"> Common use cases for lists </h3> <p> Lists are useful for a number of tasks, two very representative use cases are the following: </p> <ul> <li> Remember the latest updates posted by users into a social network. </li> <li> Communication between processes, using a consumer-producer pattern where the producer pushes items into a list, and a consumer (usually a <em> worker </em> ) consumes those items and executes actions. Redis has special list commands to make this use case both more reliable and efficient. </li> </ul> <p> For example both the popular Ruby libraries <a href="https://github.com/resque/resque"> resque </a> and <a href="https://github.com/mperham/sidekiq"> sidekiq </a> use Redis lists under the hood in order to implement background jobs. </p> <p> The popular Twitter social network <a href="http://www.infoq.com/presentations/Real-Time-Delivery-Twitter"> takes the latest tweets </a> posted by users into Redis lists. </p> <p> To describe a common use case step by step, imagine your home page shows the latest photos published in a photo sharing social network and you want to speedup access. </p> <ul> <li> Every time a user posts a new photo, we add its ID into a list with <a href="/docs/latest/commands/lpush/"> <code> LPUSH </code> </a> . </li> <li> When users visit the home page, we use <code> LRANGE 0 9 </code> in order to get the latest 10 posted items. </li> </ul> <h3 id="capped-lists"> Capped lists </h3> <p> In many use cases we just want to use lists to store the <em> latest items </em> , whatever they are: social network updates, logs, or anything else. </p> <p> Redis allows us to use lists as a capped collection, only remembering the latest N items and discarding all the oldest items using the <a href="/docs/latest/commands/ltrim/"> <code> LTRIM </code> </a> command. </p> <p> The <a href="/docs/latest/commands/ltrim/"> <code> LTRIM </code> </a> command is similar to <a href="/docs/latest/commands/lrange/"> <code> LRANGE </code> </a> , but <strong> instead of displaying the specified range of elements </strong> it sets this range as the new list value. All the elements outside the given range are removed. </p> <p> For example, if you're adding bikes on the end of a list of repairs, but only want to worry about the 3 that have been on the list the longest: </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="list_tutorial-stepltrim"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_list_tutorial-stepltrim" name="list_tutorial-stepltrim" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_list_tutorial-stepltrim" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-list_tutorial-stepltrim" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_list_tutorial-stepltrim" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; RPUSH bikes:repairs bike:1 bike:2 bike:3 bike:4 bike:5 </span></span><span class="line hl"><span class="cl">(integer) 5 </span></span><span class="line hl"><span class="cl">&gt; LTRIM bikes:repairs 0 2 </span></span><span class="line hl"><span class="cl">OK </span></span><span class="line hl"><span class="cl">&gt; LRANGE bikes:repairs 0 -1 </span></span><span class="line hl"><span class="cl">1) "bike:1" </span></span><span class="line hl"><span class="cl">2) "bike:2" </span></span><span class="line hl"><span class="cl">3) "bike:3"</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_list_tutorial-stepltrim')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_list_tutorial-stepltrim" name="list_tutorial-stepltrim" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_list_tutorial-stepltrim" title="Open example"> Python </label> <div aria-labelledby="tab-list_tutorial-stepltrim" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_list_tutorial-stepltrim" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for List doc pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/lists/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">llen</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lmove</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bikes:finished"</span><span class="p">,</span> <span class="s2">"LEFT"</span><span class="p">,</span> <span class="s2">"LEFT"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:1']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:finished"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:2']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:important_bike"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res18</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:important_bike', 'bike:1', 'bike:2']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:important_bike"</span><span class="p">,</span> <span class="s2">"bike:very_important_bike"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="n">res21</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:very_important_bike', 'bike:important_bike', 'bike:1', ...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res22</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res22</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res23</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res23</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:3'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res24</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res24</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:1'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res25</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res25</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res26</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res26</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res28</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res28</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res29</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res29</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:5', 'bike:4', 'bike:3']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res28</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res28</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res29</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res29</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:3', 'bike:4', 'bike:5']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res31</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res31</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res32</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res32</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ('bikes:repairs', 'bike:2')</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res33</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res33</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ('bikes:repairs', 'bike:1')</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res34</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res34</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res35</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res35</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res36</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res36</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res37</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res37</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res38</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">type</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res38</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'string'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">try</span><span class="p">:</span> </span></span><span class="line"><span class="cl"> <span class="n">res39</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1"># &gt;&gt;&gt; redis.exceptions.ResponseError:</span> </span></span><span class="line"><span class="cl"> <span class="c1"># &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value</span> </span></span><span class="line"><span class="cl"><span class="k">except</span> <span class="n">redis</span><span class="o">.</span><span class="n">exceptions</span><span class="o">.</span><span class="n">ResponseError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> </span></span><span class="line"><span class="cl"> <span class="nb">print</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res36</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res40</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res40</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res41</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res41</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:3'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res42</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res42</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res43</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res43</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:1'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res44</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res44</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res45</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res45</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res46</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">llen</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res46</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res47</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res47</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res48</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res48</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res49</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res49</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res50</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res50</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:5', 'bike:4', 'bike:3']</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_list_tutorial-stepltrim')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_list_tutorial-stepltrim" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_list.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_list_tutorial-stepltrim" name="list_tutorial-stepltrim" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_list_tutorial-stepltrim" title="Open example"> Node.js </label> <div aria-labelledby="tab-list_tutorial-stepltrim" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_list_tutorial-stepltrim" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">createClient</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">);</span> <span class="c1">// bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">);</span> <span class="c1">// bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">);</span> <span class="c1">// bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">);</span> <span class="c1">// bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lLen</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lMove</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bikes:finished'</span><span class="p">,</span> <span class="s1">'LEFT'</span><span class="p">,</span> <span class="s1">'LEFT'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res13</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res13</span><span class="p">);</span> <span class="c1">// ['bike:1'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:finished'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res14</span><span class="p">);</span> <span class="c1">// ['bike:2'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res15</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res15</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res16</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res16</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res17</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:important_bike'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res17</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res18</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res18</span><span class="p">);</span> <span class="c1">// ['bike:important_bike', 'bike:1', 'bike:2'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res19</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:important_bike'</span><span class="p">,</span> <span class="s1">'bike:very_important_bike'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res20</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res21</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res21</span><span class="p">);</span> <span class="c1">// ['bike:very_important_bike', 'bike:important_bike', 'bike:1', 'bike:2', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res22</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res22</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res23</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res23</span><span class="p">);</span> <span class="c1">// 'bike:3' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res24</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res24</span><span class="p">);</span> <span class="c1">// 'bike:1' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res25</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res25</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res26</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res26</span><span class="p">);</span> <span class="c1">// None </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res27</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line hl"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line hl"><span class="cl"><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res28</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res29</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29</span><span class="p">);</span> <span class="c1">// ['bike:5', 'bike:4', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res27eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27eol</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res28eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28eol</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res29eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29eol</span><span class="p">);</span> <span class="c1">// ['bike:3', 'bike:4', 'bike:5'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res31</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res31</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res32</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res32</span><span class="p">);</span> <span class="c1">// { key: 'bikes:repairs', element: 'bike:2' } </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res33</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res33</span><span class="p">);</span> <span class="c1">// { key: 'bikes:repairs', element: 'bike:1' } </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res34</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res34</span><span class="p">);</span> <span class="c1">// null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res35</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res35</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res36</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res37</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res38</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">type</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res38</span><span class="p">);</span> <span class="c1">// 'string' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="k">try</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kr">const</span> <span class="nx">res39</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// redis.exceptions.ResponseError: </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ErrorReply: WRONGTYPE Operation against a key holding the wrong kind of value] </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="k">catch</span><span class="p">(</span><span class="nx">e</span><span class="p">){</span> </span></span><span class="line"><span class="cl"> <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">e</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res40</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">exists</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res40</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res41</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res41</span><span class="p">);</span> <span class="c1">// 'bike:3' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res42</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res42</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res43</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res43</span><span class="p">);</span> <span class="c1">// 'bike:1' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res44</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">exists</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res44</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res45</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res45</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res46</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lLen</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res46</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res47</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res47</span><span class="p">);</span> <span class="c1">// null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res48</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res48</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res49</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res49</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res50</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res50</span><span class="p">);</span> <span class="c1">// ['bike:5', 'bike:4', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_list_tutorial-stepltrim')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_list_tutorial-stepltrim" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-list.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_list_tutorial-stepltrim" name="list_tutorial-stepltrim" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_list_tutorial-stepltrim" title="Open example"> Java </label> <div aria-labelledby="tab-list_tutorial-stepltrim" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_list_tutorial-stepltrim" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nn">io.redis.examples</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.junit.Test</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.args.ListDirection</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.List</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.*</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">ListExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">llen</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lmove</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bikes:finished"</span><span class="o">,</span> <span class="n">ListDirection</span><span class="o">.</span><span class="na">LEFT</span><span class="o">,</span> <span class="n">ListDirection</span><span class="o">.</span><span class="na">LEFT</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res13</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:finished"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res14</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res15</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res16</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res16</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:important_bike"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res17</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:important_bike, bike:1, bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res19</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:important_bike"</span><span class="o">,</span> <span class="s">"bike:very_important_bike"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res20</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res21</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res21</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:very_important_bike, bike:important_bike, bike:1, bike:2, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res22</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res22</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res23</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res23</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res24</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res24</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res25</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res25</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res26</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res26</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="mi">2</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res28</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:5, bike:4, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="o">-</span><span class="mi">3</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:3, bike:4, bike:5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res31</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res31</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res32</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span> <span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res32</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; (bikes:repairs, bike:2) </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res33</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res33</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; (bikes:repairs, bike:1) </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res34</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res34</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res35</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">del</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res35</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res36</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res37</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res37</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res38</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">type</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res38</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; string </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="k">try</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res39</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> <span class="k">catch</span> <span class="o">(</span><span class="n">Exception</span> <span class="n">e</span><span class="o">)</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">e</span><span class="o">.</span><span class="na">printStackTrace</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; redis.clients.jedis.exceptions.JedisDataException: </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="o">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res40</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">exists</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res40</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res41</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res41</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res42</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res42</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res43</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res43</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res44</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">exists</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res44</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res45</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">del</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res45</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res46</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">llen</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res46</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res47</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res47</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res48</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res48</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res49</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="mi">2</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res49</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res50</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res50</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:5, bike:4, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_list_tutorial-stepltrim')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_list_tutorial-stepltrim" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/ListExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_list_tutorial-stepltrim" name="list_tutorial-stepltrim" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_list_tutorial-stepltrim" title="Open example"> Go </label> <div aria-labelledby="tab-list_tutorial-stepltrim" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_list_tutorial-stepltrim" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_queue</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_stack</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_llen</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lmove_lrange</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LMove</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bikes:finished"</span><span class="p">,</span> <span class="s">"LEFT"</span><span class="p">,</span> <span class="s">"LEFT"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:finished"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lpush_rpush</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:important_bike bike:1 bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_variadic</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">,</span> <span class="s">"bike:very_important_bike"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:very_important_bike bike:important_bike bike:1 bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lpop_rpop</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res22</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res23</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res23</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res24</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res24</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res25</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res25</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res26</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res26</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;empty string&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res27</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res27</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res28</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res28</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res29</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res29</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:5 bike:4 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim_end_of_list</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res30</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res30</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res31</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res31</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res32</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res32</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:3 bike:4 bike:5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_brpop</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res33</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res33</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res34</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res34</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bikes:repairs bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res35</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res35</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bikes:repairs bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res36</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res36</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res37</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Del</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res37</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res38</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res38</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule11</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res39</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res39</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res40</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Type</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res40</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; string </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res41</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res41</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res42</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res42</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res43</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Exists</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res43</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res44</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res44</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res45</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res45</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res46</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res46</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res47</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Exists</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res47</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule3</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res48</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Del</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res48</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res49</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res49</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res50</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res50</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;empty string&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res51</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res51</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res52</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res52</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res53</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res53</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:5 bike:4 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_list_tutorial-stepltrim')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_list_tutorial-stepltrim" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/list_tutorial_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_list_tutorial-stepltrim" name="list_tutorial-stepltrim" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_list_tutorial-stepltrim" title="Open example"> C# </label> <div aria-labelledby="tab-list_tutorial-stepltrim" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_list_tutorial-stepltrim" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">ListExample</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res3</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res4</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res5</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res7</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res8</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLength</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res10</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListMove</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"{bikes}:finished"</span><span class="p">,</span> <span class="n">ListSide</span><span class="p">.</span><span class="n">Left</span><span class="p">,</span> <span class="n">ListSide</span><span class="p">.</span><span class="n">Left</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">Write</span><span class="p">(</span><span class="n">res12</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res13</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"{bikes}:finished"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res14</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res15</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res16</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res17</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res18</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:important_bike, bike:1, bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res19</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:important_bike"</span><span class="p">,</span> <span class="s">"bike:very_important_bike"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res20</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res21</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res21</span><span class="p">));</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; "bike:very_important_bike, bike:important_bike, bike:1, bike:2, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res22</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res22</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res23</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res23</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res24</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res24</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res25</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res25</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res26</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res26</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; &lt;Empty string&gt;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res27</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res27</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">2</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res28</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res28</span><span class="p">));</span> <span class="c1">// "bike:5, bike:4, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res29</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res29</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="p">-</span><span class="m">3</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res30</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res30</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:3, bike:4, bike:5"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res31</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res31</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res32</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="p">(</span><span class="n">res32</span> <span class="p">!=</span> <span class="k">null</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"{res32.Item1} -&gt; {res32.Item2}"</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bikes:repairs -&gt; bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res33</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="p">(</span><span class="n">res33</span> <span class="p">!=</span> <span class="k">null</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"{res33.Item1} -&gt; {res33.Item2}"</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bikes:repairs -&gt; bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res34</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res34</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "Null"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res35</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyDelete</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res35</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res36</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res36</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res37</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res37</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisType</span> <span class="n">res38</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyType</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res38</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; RedisType.String</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">try</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res39</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="k">catch</span> <span class="p">(</span><span class="n">Exception</span> <span class="n">e</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">e</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res40</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res40</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res41</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExists</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res41</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res42</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res42</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res43</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res43</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res44</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res44</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res45</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExists</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res45</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res46</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyDelete</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res46</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res47</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLength</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res47</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res48</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res48</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; Null</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res49</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res49</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res50</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res50</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:5, bike:4, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_list_tutorial-stepltrim')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_list_tutorial-stepltrim" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/ListTutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <p> The above <a href="/docs/latest/commands/ltrim/"> <code> LTRIM </code> </a> command tells Redis to keep just list elements from index 0 to 2, everything else will be discarded. This allows for a very simple but useful pattern: doing a List push operation + a List trim operation together to add a new element and discard elements exceeding a limit. Using <a href="/docs/latest/commands/ltrim/"> <code> LTRIM </code> </a> with negative indexes can then be used to keep only the 3 most recently added: </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="list_tutorial-stepltrim_end_of_list"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_list_tutorial-stepltrim_end_of_list" name="list_tutorial-stepltrim_end_of_list" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_list_tutorial-stepltrim_end_of_list" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-list_tutorial-stepltrim_end_of_list" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_list_tutorial-stepltrim_end_of_list" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; RPUSH bikes:repairs bike:1 bike:2 bike:3 bike:4 bike:5 </span></span><span class="line hl"><span class="cl">(integer) 5 </span></span><span class="line hl"><span class="cl">&gt; LTRIM bikes:repairs -3 -1 </span></span><span class="line hl"><span class="cl">OK </span></span><span class="line hl"><span class="cl">&gt; LRANGE bikes:repairs 0 -1 </span></span><span class="line hl"><span class="cl">1) "bike:3" </span></span><span class="line hl"><span class="cl">2) "bike:4" </span></span><span class="line hl"><span class="cl">3) "bike:5"</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_list_tutorial-stepltrim_end_of_list')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_list_tutorial-stepltrim_end_of_list" name="list_tutorial-stepltrim_end_of_list" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_list_tutorial-stepltrim_end_of_list" title="Open example"> Python </label> <div aria-labelledby="tab-list_tutorial-stepltrim_end_of_list" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_list_tutorial-stepltrim_end_of_list" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for List doc pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/lists/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">llen</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lmove</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bikes:finished"</span><span class="p">,</span> <span class="s2">"LEFT"</span><span class="p">,</span> <span class="s2">"LEFT"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:1']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:finished"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:2']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:important_bike"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res18</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:important_bike', 'bike:1', 'bike:2']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:important_bike"</span><span class="p">,</span> <span class="s2">"bike:very_important_bike"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="n">res21</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:very_important_bike', 'bike:important_bike', 'bike:1', ...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res22</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res22</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res23</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res23</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:3'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res24</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res24</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:1'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res25</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res25</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res26</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res26</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res28</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res28</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res29</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res29</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:5', 'bike:4', 'bike:3']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res28</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res28</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res29</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res29</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:3', 'bike:4', 'bike:5']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res31</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res31</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res32</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res32</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ('bikes:repairs', 'bike:2')</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res33</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res33</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ('bikes:repairs', 'bike:1')</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res34</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res34</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res35</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res35</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res36</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res36</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res37</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res37</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res38</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">type</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res38</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'string'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">try</span><span class="p">:</span> </span></span><span class="line"><span class="cl"> <span class="n">res39</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1"># &gt;&gt;&gt; redis.exceptions.ResponseError:</span> </span></span><span class="line"><span class="cl"> <span class="c1"># &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value</span> </span></span><span class="line"><span class="cl"><span class="k">except</span> <span class="n">redis</span><span class="o">.</span><span class="n">exceptions</span><span class="o">.</span><span class="n">ResponseError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> </span></span><span class="line"><span class="cl"> <span class="nb">print</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res36</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res40</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res40</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res41</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res41</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:3'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res42</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res42</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res43</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res43</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:1'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res44</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res44</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res45</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res45</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res46</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">llen</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res46</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res47</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res47</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res48</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res48</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res49</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res49</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res50</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res50</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:5', 'bike:4', 'bike:3']</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_list_tutorial-stepltrim_end_of_list')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_list_tutorial-stepltrim_end_of_list" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_list.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_list_tutorial-stepltrim_end_of_list" name="list_tutorial-stepltrim_end_of_list" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_list_tutorial-stepltrim_end_of_list" title="Open example"> Node.js </label> <div aria-labelledby="tab-list_tutorial-stepltrim_end_of_list" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_list_tutorial-stepltrim_end_of_list" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">createClient</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">);</span> <span class="c1">// bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">);</span> <span class="c1">// bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">);</span> <span class="c1">// bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">);</span> <span class="c1">// bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lLen</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lMove</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bikes:finished'</span><span class="p">,</span> <span class="s1">'LEFT'</span><span class="p">,</span> <span class="s1">'LEFT'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res13</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res13</span><span class="p">);</span> <span class="c1">// ['bike:1'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:finished'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res14</span><span class="p">);</span> <span class="c1">// ['bike:2'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res15</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res15</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res16</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res16</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res17</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:important_bike'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res17</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res18</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res18</span><span class="p">);</span> <span class="c1">// ['bike:important_bike', 'bike:1', 'bike:2'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res19</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:important_bike'</span><span class="p">,</span> <span class="s1">'bike:very_important_bike'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res20</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res21</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res21</span><span class="p">);</span> <span class="c1">// ['bike:very_important_bike', 'bike:important_bike', 'bike:1', 'bike:2', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res22</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res22</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res23</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res23</span><span class="p">);</span> <span class="c1">// 'bike:3' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res24</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res24</span><span class="p">);</span> <span class="c1">// 'bike:1' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res25</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res25</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res26</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res26</span><span class="p">);</span> <span class="c1">// None </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res27</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res28</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res29</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29</span><span class="p">);</span> <span class="c1">// ['bike:5', 'bike:4', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res27eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span> </span></span><span class="line hl"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line hl"><span class="cl"><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27eol</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res28eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28eol</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res29eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29eol</span><span class="p">);</span> <span class="c1">// ['bike:3', 'bike:4', 'bike:5'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res31</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res31</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res32</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res32</span><span class="p">);</span> <span class="c1">// { key: 'bikes:repairs', element: 'bike:2' } </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res33</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res33</span><span class="p">);</span> <span class="c1">// { key: 'bikes:repairs', element: 'bike:1' } </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res34</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res34</span><span class="p">);</span> <span class="c1">// null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res35</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res35</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res36</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res37</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res38</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">type</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res38</span><span class="p">);</span> <span class="c1">// 'string' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="k">try</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kr">const</span> <span class="nx">res39</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// redis.exceptions.ResponseError: </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ErrorReply: WRONGTYPE Operation against a key holding the wrong kind of value] </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="k">catch</span><span class="p">(</span><span class="nx">e</span><span class="p">){</span> </span></span><span class="line"><span class="cl"> <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">e</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res40</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">exists</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res40</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res41</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res41</span><span class="p">);</span> <span class="c1">// 'bike:3' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res42</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res42</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res43</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res43</span><span class="p">);</span> <span class="c1">// 'bike:1' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res44</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">exists</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res44</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res45</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res45</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res46</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lLen</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res46</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res47</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res47</span><span class="p">);</span> <span class="c1">// null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res48</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res48</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res49</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res49</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res50</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res50</span><span class="p">);</span> <span class="c1">// ['bike:5', 'bike:4', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_list_tutorial-stepltrim_end_of_list')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_list_tutorial-stepltrim_end_of_list" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-list.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_list_tutorial-stepltrim_end_of_list" name="list_tutorial-stepltrim_end_of_list" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_list_tutorial-stepltrim_end_of_list" title="Open example"> Java </label> <div aria-labelledby="tab-list_tutorial-stepltrim_end_of_list" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_list_tutorial-stepltrim_end_of_list" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nn">io.redis.examples</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.junit.Test</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.args.ListDirection</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.List</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.*</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">ListExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">llen</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lmove</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bikes:finished"</span><span class="o">,</span> <span class="n">ListDirection</span><span class="o">.</span><span class="na">LEFT</span><span class="o">,</span> <span class="n">ListDirection</span><span class="o">.</span><span class="na">LEFT</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res13</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:finished"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res14</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res15</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res16</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res16</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:important_bike"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res17</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:important_bike, bike:1, bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res19</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:important_bike"</span><span class="o">,</span> <span class="s">"bike:very_important_bike"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res20</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res21</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res21</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:very_important_bike, bike:important_bike, bike:1, bike:2, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res22</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res22</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res23</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res23</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res24</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res24</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res25</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res25</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res26</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res26</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="mi">2</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res28</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:5, bike:4, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="o">-</span><span class="mi">3</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:3, bike:4, bike:5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res31</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res31</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res32</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span> <span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res32</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; (bikes:repairs, bike:2) </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res33</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res33</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; (bikes:repairs, bike:1) </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res34</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res34</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res35</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">del</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res35</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res36</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res37</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res37</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res38</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">type</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res38</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; string </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="k">try</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res39</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> <span class="k">catch</span> <span class="o">(</span><span class="n">Exception</span> <span class="n">e</span><span class="o">)</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">e</span><span class="o">.</span><span class="na">printStackTrace</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; redis.clients.jedis.exceptions.JedisDataException: </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="o">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res40</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">exists</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res40</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res41</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res41</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res42</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res42</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res43</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res43</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res44</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">exists</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res44</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res45</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">del</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res45</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res46</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">llen</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res46</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res47</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res47</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res48</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res48</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res49</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="mi">2</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res49</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res50</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res50</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:5, bike:4, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_list_tutorial-stepltrim_end_of_list')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_list_tutorial-stepltrim_end_of_list" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/ListExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_list_tutorial-stepltrim_end_of_list" name="list_tutorial-stepltrim_end_of_list" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_list_tutorial-stepltrim_end_of_list" title="Open example"> Go </label> <div aria-labelledby="tab-list_tutorial-stepltrim_end_of_list" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_list_tutorial-stepltrim_end_of_list" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_queue</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_stack</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_llen</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lmove_lrange</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LMove</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bikes:finished"</span><span class="p">,</span> <span class="s">"LEFT"</span><span class="p">,</span> <span class="s">"LEFT"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:finished"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lpush_rpush</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:important_bike bike:1 bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_variadic</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">,</span> <span class="s">"bike:very_important_bike"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:very_important_bike bike:important_bike bike:1 bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lpop_rpop</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res22</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res23</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res23</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res24</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res24</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res25</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res25</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res26</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res26</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;empty string&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res27</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res27</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res28</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res28</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res29</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res29</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:5 bike:4 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim_end_of_list</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res30</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res30</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res31</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res31</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res32</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res32</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:3 bike:4 bike:5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_brpop</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res33</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res33</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res34</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res34</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bikes:repairs bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res35</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res35</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bikes:repairs bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res36</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res36</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res37</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Del</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res37</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res38</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res38</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule11</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res39</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res39</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res40</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Type</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res40</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; string </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res41</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res41</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res42</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res42</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res43</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Exists</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res43</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res44</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res44</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res45</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res45</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res46</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res46</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res47</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Exists</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res47</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule3</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res48</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Del</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res48</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res49</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res49</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res50</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res50</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;empty string&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res51</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res51</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res52</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res52</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res53</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res53</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:5 bike:4 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_list_tutorial-stepltrim_end_of_list')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_list_tutorial-stepltrim_end_of_list" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/list_tutorial_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_list_tutorial-stepltrim_end_of_list" name="list_tutorial-stepltrim_end_of_list" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_list_tutorial-stepltrim_end_of_list" title="Open example"> C# </label> <div aria-labelledby="tab-list_tutorial-stepltrim_end_of_list" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_list_tutorial-stepltrim_end_of_list" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">ListExample</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res3</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res4</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res5</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res7</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res8</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLength</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res10</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListMove</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"{bikes}:finished"</span><span class="p">,</span> <span class="n">ListSide</span><span class="p">.</span><span class="n">Left</span><span class="p">,</span> <span class="n">ListSide</span><span class="p">.</span><span class="n">Left</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">Write</span><span class="p">(</span><span class="n">res12</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res13</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"{bikes}:finished"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res14</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res15</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res16</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res17</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res18</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:important_bike, bike:1, bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res19</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:important_bike"</span><span class="p">,</span> <span class="s">"bike:very_important_bike"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res20</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res21</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res21</span><span class="p">));</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; "bike:very_important_bike, bike:important_bike, bike:1, bike:2, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res22</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res22</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res23</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res23</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res24</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res24</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res25</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res25</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res26</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res26</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; &lt;Empty string&gt;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res27</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res27</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res28</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res28</span><span class="p">));</span> <span class="c1">// "bike:5, bike:4, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res29</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res29</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="p">-</span><span class="m">3</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res30</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res30</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:3, bike:4, bike:5"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res31</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res31</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res32</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="p">(</span><span class="n">res32</span> <span class="p">!=</span> <span class="k">null</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"{res32.Item1} -&gt; {res32.Item2}"</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bikes:repairs -&gt; bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res33</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="p">(</span><span class="n">res33</span> <span class="p">!=</span> <span class="k">null</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"{res33.Item1} -&gt; {res33.Item2}"</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bikes:repairs -&gt; bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res34</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res34</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "Null"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res35</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyDelete</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res35</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res36</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res36</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res37</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res37</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisType</span> <span class="n">res38</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyType</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res38</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; RedisType.String</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">try</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res39</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="k">catch</span> <span class="p">(</span><span class="n">Exception</span> <span class="n">e</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">e</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res40</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res40</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res41</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExists</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res41</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res42</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res42</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res43</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res43</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res44</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res44</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res45</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExists</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res45</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res46</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyDelete</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res46</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res47</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLength</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res47</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res48</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res48</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; Null</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res49</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res49</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res50</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res50</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:5, bike:4, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_list_tutorial-stepltrim_end_of_list')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_list_tutorial-stepltrim_end_of_list" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/ListTutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <p> The above combination adds new elements and keeps only the 3 newest elements into the list. With <a href="/docs/latest/commands/lrange/"> <code> LRANGE </code> </a> you can access the top items without any need to remember very old data. </p> <p> Note: while <a href="/docs/latest/commands/lrange/"> <code> LRANGE </code> </a> is technically an O(N) command, accessing small ranges towards the head or the tail of the list is a constant time operation. </p> <h2 id="blocking-operations-on-lists"> Blocking operations on lists </h2> <p> Lists have a special feature that make them suitable to implement queues, and in general as a building block for inter process communication systems: blocking operations. </p> <p> Imagine you want to push items into a list with one process, and use a different process in order to actually do some kind of work with those items. This is the usual producer / consumer setup, and can be implemented in the following simple way: </p> <ul> <li> To push items into the list, producers call <a href="/docs/latest/commands/lpush/"> <code> LPUSH </code> </a> . </li> <li> To extract / process items from the list, consumers call <a href="/docs/latest/commands/rpop/"> <code> RPOP </code> </a> . </li> </ul> <p> However it is possible that sometimes the list is empty and there is nothing to process, so <a href="/docs/latest/commands/rpop/"> <code> RPOP </code> </a> just returns NULL. In this case a consumer is forced to wait some time and retry again with <a href="/docs/latest/commands/rpop/"> <code> RPOP </code> </a> . This is called <em> polling </em> , and is not a good idea in this context because it has several drawbacks: </p> <ol> <li> Forces Redis and clients to process useless commands (all the requests when the list is empty will get no actual work done, they'll just return NULL). </li> <li> Adds a delay to the processing of items, since after a worker receives a NULL, it waits some time. To make the delay smaller, we could wait less between calls to <a href="/docs/latest/commands/rpop/"> <code> RPOP </code> </a> , with the effect of amplifying problem number 1, i.e. more useless calls to Redis. </li> </ol> <p> So Redis implements commands called <a href="/docs/latest/commands/brpop/"> <code> BRPOP </code> </a> and <a href="/docs/latest/commands/blpop/"> <code> BLPOP </code> </a> which are versions of <a href="/docs/latest/commands/rpop/"> <code> RPOP </code> </a> and <a href="/docs/latest/commands/lpop/"> <code> LPOP </code> </a> able to block if the list is empty: they'll return to the caller only when a new element is added to the list, or when a user-specified timeout is reached. </p> <p> This is an example of a <a href="/docs/latest/commands/brpop/"> <code> BRPOP </code> </a> call we could use in the worker: </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="list_tutorial-stepbrpop"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_list_tutorial-stepbrpop" name="list_tutorial-stepbrpop" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_list_tutorial-stepbrpop" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-list_tutorial-stepbrpop" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_list_tutorial-stepbrpop" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; RPUSH bikes:repairs bike:1 bike:2 </span></span><span class="line hl"><span class="cl">(integer) 2 </span></span><span class="line hl"><span class="cl">&gt; BRPOP bikes:repairs 1 </span></span><span class="line hl"><span class="cl">1) "bikes:repairs" </span></span><span class="line hl"><span class="cl">2) "bike:2" </span></span><span class="line hl"><span class="cl">&gt; BRPOP bikes:repairs 1 </span></span><span class="line hl"><span class="cl">1) "bikes:repairs" </span></span><span class="line hl"><span class="cl">2) "bike:1" </span></span><span class="line hl"><span class="cl">&gt; BRPOP bikes:repairs 1 </span></span><span class="line hl"><span class="cl">(nil) </span></span><span class="line hl"><span class="cl">(2.01s)</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_list_tutorial-stepbrpop')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_list_tutorial-stepbrpop" name="list_tutorial-stepbrpop" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_list_tutorial-stepbrpop" title="Open example"> Python </label> <div aria-labelledby="tab-list_tutorial-stepbrpop" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_list_tutorial-stepbrpop" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for List doc pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/lists/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">llen</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lmove</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bikes:finished"</span><span class="p">,</span> <span class="s2">"LEFT"</span><span class="p">,</span> <span class="s2">"LEFT"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:1']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:finished"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:2']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:important_bike"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res18</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:important_bike', 'bike:1', 'bike:2']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:important_bike"</span><span class="p">,</span> <span class="s2">"bike:very_important_bike"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="n">res21</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:very_important_bike', 'bike:important_bike', 'bike:1', ...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res22</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res22</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res23</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res23</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:3'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res24</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res24</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:1'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res25</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res25</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res26</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res26</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res28</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res28</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res29</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res29</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:5', 'bike:4', 'bike:3']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res28</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res28</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res29</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res29</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:3', 'bike:4', 'bike:5']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res31</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res31</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res32</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res32</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ('bikes:repairs', 'bike:2')</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res33</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res33</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ('bikes:repairs', 'bike:1')</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res34</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res34</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res35</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res35</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res36</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res36</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res37</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res37</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res38</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">type</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res38</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'string'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">try</span><span class="p">:</span> </span></span><span class="line"><span class="cl"> <span class="n">res39</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1"># &gt;&gt;&gt; redis.exceptions.ResponseError:</span> </span></span><span class="line"><span class="cl"> <span class="c1"># &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value</span> </span></span><span class="line"><span class="cl"><span class="k">except</span> <span class="n">redis</span><span class="o">.</span><span class="n">exceptions</span><span class="o">.</span><span class="n">ResponseError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> </span></span><span class="line"><span class="cl"> <span class="nb">print</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res36</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res40</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res40</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res41</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res41</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:3'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res42</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res42</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res43</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res43</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:1'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res44</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res44</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res45</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res45</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res46</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">llen</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res46</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res47</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res47</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res48</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res48</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res49</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res49</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res50</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res50</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:5', 'bike:4', 'bike:3']</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_list_tutorial-stepbrpop')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_list_tutorial-stepbrpop" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_list.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_list_tutorial-stepbrpop" name="list_tutorial-stepbrpop" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_list_tutorial-stepbrpop" title="Open example"> Node.js </label> <div aria-labelledby="tab-list_tutorial-stepbrpop" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_list_tutorial-stepbrpop" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">createClient</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">);</span> <span class="c1">// bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">);</span> <span class="c1">// bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">);</span> <span class="c1">// bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">);</span> <span class="c1">// bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lLen</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lMove</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bikes:finished'</span><span class="p">,</span> <span class="s1">'LEFT'</span><span class="p">,</span> <span class="s1">'LEFT'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res13</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res13</span><span class="p">);</span> <span class="c1">// ['bike:1'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:finished'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res14</span><span class="p">);</span> <span class="c1">// ['bike:2'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res15</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res15</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res16</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res16</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res17</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:important_bike'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res17</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res18</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res18</span><span class="p">);</span> <span class="c1">// ['bike:important_bike', 'bike:1', 'bike:2'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res19</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:important_bike'</span><span class="p">,</span> <span class="s1">'bike:very_important_bike'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res20</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res21</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res21</span><span class="p">);</span> <span class="c1">// ['bike:very_important_bike', 'bike:important_bike', 'bike:1', 'bike:2', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res22</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res22</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res23</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res23</span><span class="p">);</span> <span class="c1">// 'bike:3' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res24</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res24</span><span class="p">);</span> <span class="c1">// 'bike:1' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res25</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res25</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res26</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res26</span><span class="p">);</span> <span class="c1">// None </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res27</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res28</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res29</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29</span><span class="p">);</span> <span class="c1">// ['bike:5', 'bike:4', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res27eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27eol</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res28eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28eol</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res29eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29eol</span><span class="p">);</span> <span class="c1">// ['bike:3', 'bike:4', 'bike:5'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res31</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">]);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res31</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res32</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res32</span><span class="p">);</span> <span class="c1">// { key: 'bikes:repairs', element: 'bike:2' } </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res33</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res33</span><span class="p">);</span> <span class="c1">// { key: 'bikes:repairs', element: 'bike:1' } </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res34</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res34</span><span class="p">);</span> <span class="c1">// null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res35</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res35</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res36</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res37</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res38</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">type</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res38</span><span class="p">);</span> <span class="c1">// 'string' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="k">try</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kr">const</span> <span class="nx">res39</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// redis.exceptions.ResponseError: </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ErrorReply: WRONGTYPE Operation against a key holding the wrong kind of value] </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="k">catch</span><span class="p">(</span><span class="nx">e</span><span class="p">){</span> </span></span><span class="line"><span class="cl"> <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">e</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res40</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">exists</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res40</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res41</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res41</span><span class="p">);</span> <span class="c1">// 'bike:3' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res42</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res42</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res43</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res43</span><span class="p">);</span> <span class="c1">// 'bike:1' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res44</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">exists</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res44</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res45</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res45</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res46</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lLen</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res46</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res47</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res47</span><span class="p">);</span> <span class="c1">// null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res48</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res48</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res49</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res49</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res50</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res50</span><span class="p">);</span> <span class="c1">// ['bike:5', 'bike:4', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_list_tutorial-stepbrpop')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_list_tutorial-stepbrpop" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-list.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_list_tutorial-stepbrpop" name="list_tutorial-stepbrpop" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_list_tutorial-stepbrpop" title="Open example"> Java </label> <div aria-labelledby="tab-list_tutorial-stepbrpop" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_list_tutorial-stepbrpop" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nn">io.redis.examples</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.junit.Test</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.args.ListDirection</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.List</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.*</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">ListExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">llen</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lmove</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bikes:finished"</span><span class="o">,</span> <span class="n">ListDirection</span><span class="o">.</span><span class="na">LEFT</span><span class="o">,</span> <span class="n">ListDirection</span><span class="o">.</span><span class="na">LEFT</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res13</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:finished"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res14</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res15</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res16</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res16</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:important_bike"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res17</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:important_bike, bike:1, bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res19</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:important_bike"</span><span class="o">,</span> <span class="s">"bike:very_important_bike"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res20</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res21</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res21</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:very_important_bike, bike:important_bike, bike:1, bike:2, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res22</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res22</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res23</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res23</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res24</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res24</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res25</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res25</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res26</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res26</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="mi">2</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res28</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:5, bike:4, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="o">-</span><span class="mi">3</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:3, bike:4, bike:5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res31</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res31</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res32</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span> <span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res32</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; (bikes:repairs, bike:2) </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res33</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res33</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; (bikes:repairs, bike:1) </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res34</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res34</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res35</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">del</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res35</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res36</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res37</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res37</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res38</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">type</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res38</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; string </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="k">try</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res39</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> <span class="k">catch</span> <span class="o">(</span><span class="n">Exception</span> <span class="n">e</span><span class="o">)</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">e</span><span class="o">.</span><span class="na">printStackTrace</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; redis.clients.jedis.exceptions.JedisDataException: </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="o">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res40</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">exists</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res40</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res41</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res41</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res42</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res42</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res43</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res43</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res44</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">exists</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res44</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res45</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">del</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res45</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res46</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">llen</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res46</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res47</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res47</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res48</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res48</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res49</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="mi">2</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res49</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res50</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res50</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:5, bike:4, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_list_tutorial-stepbrpop')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_list_tutorial-stepbrpop" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/ListExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_list_tutorial-stepbrpop" name="list_tutorial-stepbrpop" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_list_tutorial-stepbrpop" title="Open example"> Go </label> <div aria-labelledby="tab-list_tutorial-stepbrpop" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_list_tutorial-stepbrpop" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_queue</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_stack</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_llen</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lmove_lrange</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LMove</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bikes:finished"</span><span class="p">,</span> <span class="s">"LEFT"</span><span class="p">,</span> <span class="s">"LEFT"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:finished"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lpush_rpush</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:important_bike bike:1 bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_variadic</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">,</span> <span class="s">"bike:very_important_bike"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:very_important_bike bike:important_bike bike:1 bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lpop_rpop</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res22</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res23</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res23</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res24</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res24</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res25</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res25</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res26</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res26</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;empty string&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res27</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res27</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res28</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res28</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res29</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res29</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:5 bike:4 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim_end_of_list</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res30</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res30</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res31</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res31</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res32</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res32</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:3 bike:4 bike:5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_brpop</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res33</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res33</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res34</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res34</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bikes:repairs bike:2] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res35</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res35</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bikes:repairs bike:1] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res36</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res36</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res37</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Del</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res37</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res38</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res38</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule11</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res39</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res39</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res40</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Type</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res40</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; string </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res41</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res41</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res42</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res42</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res43</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Exists</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res43</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res44</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res44</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res45</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res45</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res46</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res46</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res47</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Exists</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res47</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule3</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res48</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Del</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res48</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res49</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res49</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res50</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res50</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;empty string&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res51</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res51</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res52</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res52</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res53</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res53</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:5 bike:4 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_list_tutorial-stepbrpop')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_list_tutorial-stepbrpop" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/list_tutorial_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_list_tutorial-stepbrpop" name="list_tutorial-stepbrpop" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_list_tutorial-stepbrpop" title="Open example"> C# </label> <div aria-labelledby="tab-list_tutorial-stepbrpop" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_list_tutorial-stepbrpop" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">ListExample</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res3</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res4</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res5</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res7</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res8</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLength</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res10</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListMove</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"{bikes}:finished"</span><span class="p">,</span> <span class="n">ListSide</span><span class="p">.</span><span class="n">Left</span><span class="p">,</span> <span class="n">ListSide</span><span class="p">.</span><span class="n">Left</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">Write</span><span class="p">(</span><span class="n">res12</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res13</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"{bikes}:finished"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res14</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res15</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res16</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res17</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res18</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:important_bike, bike:1, bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res19</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:important_bike"</span><span class="p">,</span> <span class="s">"bike:very_important_bike"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res20</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res21</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res21</span><span class="p">));</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; "bike:very_important_bike, bike:important_bike, bike:1, bike:2, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res22</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res22</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res23</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res23</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res24</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res24</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res25</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res25</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res26</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res26</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; &lt;Empty string&gt;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res27</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res27</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res28</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res28</span><span class="p">));</span> <span class="c1">// "bike:5, bike:4, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res29</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res29</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="p">-</span><span class="m">3</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res30</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res30</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:3, bike:4, bike:5"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res31</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res31</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res32</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="p">(</span><span class="n">res32</span> <span class="p">!=</span> <span class="k">null</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"{res32.Item1} -&gt; {res32.Item2}"</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bikes:repairs -&gt; bike:2"</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res33</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="p">(</span><span class="n">res33</span> <span class="p">!=</span> <span class="k">null</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"{res33.Item1} -&gt; {res33.Item2}"</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bikes:repairs -&gt; bike:1"</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res34</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res34</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "Null"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res35</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyDelete</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res35</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res36</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res36</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res37</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res37</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisType</span> <span class="n">res38</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyType</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res38</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; RedisType.String</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">try</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res39</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="k">catch</span> <span class="p">(</span><span class="n">Exception</span> <span class="n">e</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">e</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res40</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res40</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res41</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExists</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res41</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res42</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res42</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res43</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res43</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res44</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res44</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res45</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExists</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res45</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res46</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyDelete</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res46</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res47</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLength</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res47</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res48</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res48</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; Null</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res49</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res49</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res50</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res50</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:5, bike:4, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_list_tutorial-stepbrpop')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_list_tutorial-stepbrpop" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/ListTutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <p> It means: "wait for elements in the list <code> bikes:repairs </code> , but return if after 1 second no element is available". </p> <p> Note that you can use 0 as timeout to wait for elements forever, and you can also specify multiple lists and not just one, in order to wait on multiple lists at the same time, and get notified when the first list receives an element. </p> <p> A few things to note about <a href="/docs/latest/commands/brpop/"> <code> BRPOP </code> </a> : </p> <ol> <li> Clients are served in an ordered way: the first client that blocked waiting for a list, is served first when an element is pushed by some other client, and so forth. </li> <li> The return value is different compared to <a href="/docs/latest/commands/rpop/"> <code> RPOP </code> </a> : it is a two-element array since it also includes the name of the key, because <a href="/docs/latest/commands/brpop/"> <code> BRPOP </code> </a> and <a href="/docs/latest/commands/blpop/"> <code> BLPOP </code> </a> are able to block waiting for elements from multiple lists. </li> <li> If the timeout is reached, NULL is returned. </li> </ol> <p> There are more things you should know about lists and blocking ops. We suggest that you read more on the following: </p> <ul> <li> It is possible to build safer queues or rotating queues using <a href="/docs/latest/commands/lmove/"> <code> LMOVE </code> </a> . </li> <li> There is also a blocking variant of the command, called <a href="/docs/latest/commands/blmove/"> <code> BLMOVE </code> </a> . </li> </ul> <h2 id="automatic-creation-and-removal-of-keys"> Automatic creation and removal of keys </h2> <p> So far in our examples we never had to create empty lists before pushing elements, or removing empty lists when they no longer have elements inside. It is Redis' responsibility to delete keys when lists are left empty, or to create an empty list if the key does not exist and we are trying to add elements to it, for example, with <a href="/docs/latest/commands/lpush/"> <code> LPUSH </code> </a> . </p> <p> This is not specific to lists, it applies to all the Redis data types composed of multiple elements -- Streams, Sets, Sorted Sets and Hashes. </p> <p> Basically we can summarize the behavior with three rules: </p> <ol> <li> When we add an element to an aggregate data type, if the target key does not exist, an empty aggregate data type is created before adding the element. </li> <li> When we remove elements from an aggregate data type, if the value remains empty, the key is automatically destroyed. The Stream data type is the only exception to this rule. </li> <li> Calling a read-only command such as <a href="/docs/latest/commands/llen/"> <code> LLEN </code> </a> (which returns the length of the list), or a write command removing elements, with an empty key, always produces the same result as if the key is holding an empty aggregate type of the type the command expects to find. </li> </ol> <p> Examples of rule 1: </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="list_tutorial-steprule_1"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_list_tutorial-steprule_1" name="list_tutorial-steprule_1" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_list_tutorial-steprule_1" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-list_tutorial-steprule_1" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_list_tutorial-steprule_1" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; DEL new_bikes </span></span><span class="line hl"><span class="cl">(integer) 0 </span></span><span class="line hl"><span class="cl">&gt; LPUSH new_bikes bike:1 bike:2 bike:3 </span></span><span class="line hl"><span class="cl">(integer) 3</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_list_tutorial-steprule_1')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_list_tutorial-steprule_1" name="list_tutorial-steprule_1" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_list_tutorial-steprule_1" title="Open example"> Python </label> <div aria-labelledby="tab-list_tutorial-steprule_1" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_list_tutorial-steprule_1" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for List doc pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/lists/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">llen</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lmove</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bikes:finished"</span><span class="p">,</span> <span class="s2">"LEFT"</span><span class="p">,</span> <span class="s2">"LEFT"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:1']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:finished"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:2']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:important_bike"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res18</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:important_bike', 'bike:1', 'bike:2']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:important_bike"</span><span class="p">,</span> <span class="s2">"bike:very_important_bike"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="n">res21</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:very_important_bike', 'bike:important_bike', 'bike:1', ...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res22</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res22</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res23</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res23</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:3'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res24</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res24</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:1'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res25</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res25</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res26</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res26</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res28</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res28</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res29</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res29</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:5', 'bike:4', 'bike:3']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res28</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res28</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res29</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res29</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:3', 'bike:4', 'bike:5']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res31</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res31</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res32</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res32</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ('bikes:repairs', 'bike:2')</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res33</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res33</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ('bikes:repairs', 'bike:1')</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res34</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res34</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res35</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res35</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res36</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res36</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res37</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res37</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res38</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">type</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res38</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'string'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">try</span><span class="p">:</span> </span></span><span class="line"><span class="cl"> <span class="n">res39</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1"># &gt;&gt;&gt; redis.exceptions.ResponseError:</span> </span></span><span class="line"><span class="cl"> <span class="c1"># &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value</span> </span></span><span class="line"><span class="cl"><span class="k">except</span> <span class="n">redis</span><span class="o">.</span><span class="n">exceptions</span><span class="o">.</span><span class="n">ResponseError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> </span></span><span class="line"><span class="cl"> <span class="nb">print</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res36</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res40</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res40</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res41</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res41</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:3'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res42</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res42</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res43</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res43</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:1'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res44</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res44</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res45</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res45</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res46</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">llen</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res46</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res47</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res47</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res48</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res48</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res49</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res49</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res50</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res50</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:5', 'bike:4', 'bike:3']</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_list_tutorial-steprule_1')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_list_tutorial-steprule_1" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_list.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_list_tutorial-steprule_1" name="list_tutorial-steprule_1" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_list_tutorial-steprule_1" title="Open example"> Node.js </label> <div aria-labelledby="tab-list_tutorial-steprule_1" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_list_tutorial-steprule_1" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">createClient</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">);</span> <span class="c1">// bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">);</span> <span class="c1">// bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">);</span> <span class="c1">// bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">);</span> <span class="c1">// bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lLen</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lMove</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bikes:finished'</span><span class="p">,</span> <span class="s1">'LEFT'</span><span class="p">,</span> <span class="s1">'LEFT'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res13</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res13</span><span class="p">);</span> <span class="c1">// ['bike:1'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:finished'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res14</span><span class="p">);</span> <span class="c1">// ['bike:2'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res15</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res15</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res16</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res16</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res17</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:important_bike'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res17</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res18</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res18</span><span class="p">);</span> <span class="c1">// ['bike:important_bike', 'bike:1', 'bike:2'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res19</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:important_bike'</span><span class="p">,</span> <span class="s1">'bike:very_important_bike'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res20</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res21</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res21</span><span class="p">);</span> <span class="c1">// ['bike:very_important_bike', 'bike:important_bike', 'bike:1', 'bike:2', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res22</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res22</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res23</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res23</span><span class="p">);</span> <span class="c1">// 'bike:3' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res24</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res24</span><span class="p">);</span> <span class="c1">// 'bike:1' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res25</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res25</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res26</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res26</span><span class="p">);</span> <span class="c1">// None </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res27</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res28</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res29</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29</span><span class="p">);</span> <span class="c1">// ['bike:5', 'bike:4', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res27eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27eol</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res28eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28eol</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res29eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29eol</span><span class="p">);</span> <span class="c1">// ['bike:3', 'bike:4', 'bike:5'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res31</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res31</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res32</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res32</span><span class="p">);</span> <span class="c1">// { key: 'bikes:repairs', element: 'bike:2' } </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res33</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res33</span><span class="p">);</span> <span class="c1">// { key: 'bikes:repairs', element: 'bike:1' } </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res34</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res34</span><span class="p">);</span> <span class="c1">// null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res35</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res35</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res36</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res37</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res38</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">type</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res38</span><span class="p">);</span> <span class="c1">// 'string' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="k">try</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kr">const</span> <span class="nx">res39</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// redis.exceptions.ResponseError: </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ErrorReply: WRONGTYPE Operation against a key holding the wrong kind of value] </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="k">catch</span><span class="p">(</span><span class="nx">e</span><span class="p">){</span> </span></span><span class="line"><span class="cl"> <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">e</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res40</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">exists</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res40</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res41</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res41</span><span class="p">);</span> <span class="c1">// 'bike:3' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res42</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res42</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res43</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res43</span><span class="p">);</span> <span class="c1">// 'bike:1' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res44</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">exists</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res44</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res45</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res45</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res46</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lLen</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res46</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res47</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res47</span><span class="p">);</span> <span class="c1">// null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res48</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res48</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res49</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res49</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res50</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res50</span><span class="p">);</span> <span class="c1">// ['bike:5', 'bike:4', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_list_tutorial-steprule_1')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_list_tutorial-steprule_1" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-list.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_list_tutorial-steprule_1" name="list_tutorial-steprule_1" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_list_tutorial-steprule_1" title="Open example"> Java </label> <div aria-labelledby="tab-list_tutorial-steprule_1" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_list_tutorial-steprule_1" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nn">io.redis.examples</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.junit.Test</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.args.ListDirection</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.List</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.*</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">ListExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">llen</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lmove</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bikes:finished"</span><span class="o">,</span> <span class="n">ListDirection</span><span class="o">.</span><span class="na">LEFT</span><span class="o">,</span> <span class="n">ListDirection</span><span class="o">.</span><span class="na">LEFT</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res13</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:finished"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res14</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res15</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res16</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res16</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:important_bike"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res17</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:important_bike, bike:1, bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res19</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:important_bike"</span><span class="o">,</span> <span class="s">"bike:very_important_bike"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res20</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res21</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res21</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:very_important_bike, bike:important_bike, bike:1, bike:2, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res22</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res22</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res23</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res23</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res24</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res24</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res25</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res25</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res26</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res26</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="mi">2</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res28</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:5, bike:4, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="o">-</span><span class="mi">3</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:3, bike:4, bike:5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res31</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res31</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res32</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span> <span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res32</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; (bikes:repairs, bike:2) </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res33</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res33</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; (bikes:repairs, bike:1) </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res34</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res34</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res35</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">del</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res35</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res36</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res37</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res37</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res38</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">type</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res38</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; string </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="k">try</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res39</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> <span class="k">catch</span> <span class="o">(</span><span class="n">Exception</span> <span class="n">e</span><span class="o">)</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">e</span><span class="o">.</span><span class="na">printStackTrace</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; redis.clients.jedis.exceptions.JedisDataException: </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="o">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res40</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">exists</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res40</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res41</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res41</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res42</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res42</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res43</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res43</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res44</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">exists</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res44</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res45</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">del</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res45</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res46</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">llen</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res46</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res47</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res47</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res48</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res48</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res49</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="mi">2</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res49</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res50</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res50</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:5, bike:4, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_list_tutorial-steprule_1')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_list_tutorial-steprule_1" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/ListExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_list_tutorial-steprule_1" name="list_tutorial-steprule_1" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_list_tutorial-steprule_1" title="Open example"> Go </label> <div aria-labelledby="tab-list_tutorial-steprule_1" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_list_tutorial-steprule_1" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_queue</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_stack</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_llen</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lmove_lrange</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LMove</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bikes:finished"</span><span class="p">,</span> <span class="s">"LEFT"</span><span class="p">,</span> <span class="s">"LEFT"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:finished"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lpush_rpush</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:important_bike bike:1 bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_variadic</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">,</span> <span class="s">"bike:very_important_bike"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:very_important_bike bike:important_bike bike:1 bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lpop_rpop</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res22</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res23</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res23</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res24</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res24</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res25</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res25</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res26</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res26</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;empty string&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res27</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res27</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res28</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res28</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res29</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res29</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:5 bike:4 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim_end_of_list</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res30</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res30</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res31</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res31</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res32</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res32</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:3 bike:4 bike:5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_brpop</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res33</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res33</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res34</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res34</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bikes:repairs bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res35</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res35</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bikes:repairs bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res36</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res36</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res37</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Del</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res37</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res38</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res38</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule11</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res39</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res39</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res40</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Type</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res40</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; string </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res41</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res41</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res42</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res42</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res43</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Exists</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res43</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res44</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res44</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res45</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res45</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res46</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res46</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res47</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Exists</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res47</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule3</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res48</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Del</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res48</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res49</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res49</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res50</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res50</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;empty string&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res51</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res51</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res52</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res52</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res53</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res53</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:5 bike:4 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_list_tutorial-steprule_1')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_list_tutorial-steprule_1" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/list_tutorial_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_list_tutorial-steprule_1" name="list_tutorial-steprule_1" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_list_tutorial-steprule_1" title="Open example"> C# </label> <div aria-labelledby="tab-list_tutorial-steprule_1" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_list_tutorial-steprule_1" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">ListExample</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res3</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res4</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res5</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res7</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res8</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLength</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res10</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListMove</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"{bikes}:finished"</span><span class="p">,</span> <span class="n">ListSide</span><span class="p">.</span><span class="n">Left</span><span class="p">,</span> <span class="n">ListSide</span><span class="p">.</span><span class="n">Left</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">Write</span><span class="p">(</span><span class="n">res12</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res13</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"{bikes}:finished"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res14</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res15</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res16</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res17</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res18</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:important_bike, bike:1, bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res19</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:important_bike"</span><span class="p">,</span> <span class="s">"bike:very_important_bike"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res20</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res21</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res21</span><span class="p">));</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; "bike:very_important_bike, bike:important_bike, bike:1, bike:2, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res22</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res22</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res23</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res23</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res24</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res24</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res25</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res25</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res26</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res26</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; &lt;Empty string&gt;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res27</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res27</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res28</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res28</span><span class="p">));</span> <span class="c1">// "bike:5, bike:4, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res29</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res29</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="p">-</span><span class="m">3</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res30</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res30</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:3, bike:4, bike:5"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res31</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res31</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res32</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="p">(</span><span class="n">res32</span> <span class="p">!=</span> <span class="k">null</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"{res32.Item1} -&gt; {res32.Item2}"</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bikes:repairs -&gt; bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res33</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="p">(</span><span class="n">res33</span> <span class="p">!=</span> <span class="k">null</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"{res33.Item1} -&gt; {res33.Item2}"</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bikes:repairs -&gt; bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res34</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res34</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "Null"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">bool</span> <span class="n">res35</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyDelete</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res35</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res36</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res36</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res37</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res37</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisType</span> <span class="n">res38</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyType</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res38</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; RedisType.String</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">try</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res39</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="k">catch</span> <span class="p">(</span><span class="n">Exception</span> <span class="n">e</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">e</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res40</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res40</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res41</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExists</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res41</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res42</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res42</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res43</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res43</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res44</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res44</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res45</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExists</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res45</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res46</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyDelete</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res46</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res47</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLength</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res47</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res48</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res48</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; Null</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res49</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res49</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res50</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res50</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:5, bike:4, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_list_tutorial-steprule_1')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_list_tutorial-steprule_1" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/ListTutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <p> However we can't perform operations against the wrong type if the key exists: </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="list_tutorial-steprule_1.1"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_list_tutorial-steprule_1.1" name="list_tutorial-steprule_1.1" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_list_tutorial-steprule_1.1" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-list_tutorial-steprule_1.1" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_list_tutorial-steprule_1.1" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; SET new_bikes bike:1 </span></span><span class="line hl"><span class="cl">OK </span></span><span class="line hl"><span class="cl">&gt; TYPE new_bikes </span></span><span class="line hl"><span class="cl">string </span></span><span class="line hl"><span class="cl">&gt; LPUSH new_bikes bike:2 bike:3 </span></span><span class="line hl"><span class="cl">(error) WRONGTYPE Operation against a key holding the wrong kind of value</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_list_tutorial-steprule_1.1')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_list_tutorial-steprule_1.1" name="list_tutorial-steprule_1.1" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_list_tutorial-steprule_1.1" title="Open example"> Python </label> <div aria-labelledby="tab-list_tutorial-steprule_1.1" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_list_tutorial-steprule_1.1" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for List doc pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/lists/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">llen</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lmove</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bikes:finished"</span><span class="p">,</span> <span class="s2">"LEFT"</span><span class="p">,</span> <span class="s2">"LEFT"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:1']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:finished"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:2']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:important_bike"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res18</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:important_bike', 'bike:1', 'bike:2']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:important_bike"</span><span class="p">,</span> <span class="s2">"bike:very_important_bike"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="n">res21</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:very_important_bike', 'bike:important_bike', 'bike:1', ...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res22</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res22</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res23</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res23</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:3'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res24</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res24</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:1'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res25</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res25</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res26</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res26</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res28</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res28</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res29</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res29</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:5', 'bike:4', 'bike:3']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res28</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res28</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res29</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res29</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:3', 'bike:4', 'bike:5']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res31</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res31</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res32</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res32</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ('bikes:repairs', 'bike:2')</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res33</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res33</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ('bikes:repairs', 'bike:1')</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res34</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res34</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res35</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res35</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res36</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res36</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res37</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res37</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res38</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">type</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res38</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'string'</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="k">try</span><span class="p">:</span> </span></span><span class="line hl"><span class="cl"> <span class="n">res39</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="c1"># &gt;&gt;&gt; redis.exceptions.ResponseError:</span> </span></span><span class="line hl"><span class="cl"> <span class="c1"># &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value</span> </span></span><span class="line hl"><span class="cl"><span class="k">except</span> <span class="n">redis</span><span class="o">.</span><span class="n">exceptions</span><span class="o">.</span><span class="n">ResponseError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">print</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res36</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res40</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res40</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res41</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res41</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:3'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res42</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res42</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res43</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res43</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:1'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res44</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res44</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res45</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res45</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res46</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">llen</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res46</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res47</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res47</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res48</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res48</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res49</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res49</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res50</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res50</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:5', 'bike:4', 'bike:3']</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_list_tutorial-steprule_1.1')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_list_tutorial-steprule_1.1" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_list.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_list_tutorial-steprule_1.1" name="list_tutorial-steprule_1.1" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_list_tutorial-steprule_1.1" title="Open example"> Node.js </label> <div aria-labelledby="tab-list_tutorial-steprule_1.1" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_list_tutorial-steprule_1.1" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">createClient</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">);</span> <span class="c1">// bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">);</span> <span class="c1">// bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">);</span> <span class="c1">// bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">);</span> <span class="c1">// bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lLen</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lMove</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bikes:finished'</span><span class="p">,</span> <span class="s1">'LEFT'</span><span class="p">,</span> <span class="s1">'LEFT'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res13</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res13</span><span class="p">);</span> <span class="c1">// ['bike:1'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:finished'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res14</span><span class="p">);</span> <span class="c1">// ['bike:2'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res15</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res15</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res16</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res16</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res17</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:important_bike'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res17</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res18</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res18</span><span class="p">);</span> <span class="c1">// ['bike:important_bike', 'bike:1', 'bike:2'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res19</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:important_bike'</span><span class="p">,</span> <span class="s1">'bike:very_important_bike'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res20</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res21</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res21</span><span class="p">);</span> <span class="c1">// ['bike:very_important_bike', 'bike:important_bike', 'bike:1', 'bike:2', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res22</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res22</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res23</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res23</span><span class="p">);</span> <span class="c1">// 'bike:3' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res24</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res24</span><span class="p">);</span> <span class="c1">// 'bike:1' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res25</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res25</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res26</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res26</span><span class="p">);</span> <span class="c1">// None </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res27</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res28</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res29</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29</span><span class="p">);</span> <span class="c1">// ['bike:5', 'bike:4', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res27eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27eol</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res28eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28eol</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res29eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29eol</span><span class="p">);</span> <span class="c1">// ['bike:3', 'bike:4', 'bike:5'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res31</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res31</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res32</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res32</span><span class="p">);</span> <span class="c1">// { key: 'bikes:repairs', element: 'bike:2' } </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res33</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res33</span><span class="p">);</span> <span class="c1">// { key: 'bikes:repairs', element: 'bike:1' } </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res34</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res34</span><span class="p">);</span> <span class="c1">// null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res35</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res35</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res36</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res37</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res37</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res38</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">type</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res38</span><span class="p">);</span> <span class="c1">// 'string' </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="k">try</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="kr">const</span> <span class="nx">res39</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="c1">// redis.exceptions.ResponseError: </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="c1">// [ErrorReply: WRONGTYPE Operation against a key holding the wrong kind of value] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span><span class="p">}</span> </span></span><span class="line hl"><span class="cl"><span class="k">catch</span><span class="p">(</span><span class="nx">e</span><span class="p">){</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">e</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res40</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">exists</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res40</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res41</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res41</span><span class="p">);</span> <span class="c1">// 'bike:3' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res42</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res42</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res43</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res43</span><span class="p">);</span> <span class="c1">// 'bike:1' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res44</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">exists</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res44</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res45</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res45</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res46</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lLen</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res46</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res47</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res47</span><span class="p">);</span> <span class="c1">// null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res48</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res48</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res49</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res49</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res50</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res50</span><span class="p">);</span> <span class="c1">// ['bike:5', 'bike:4', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_list_tutorial-steprule_1.1')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_list_tutorial-steprule_1.1" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-list.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_list_tutorial-steprule_1.1" name="list_tutorial-steprule_1.1" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_list_tutorial-steprule_1.1" title="Open example"> Java </label> <div aria-labelledby="tab-list_tutorial-steprule_1.1" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_list_tutorial-steprule_1.1" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nn">io.redis.examples</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.junit.Test</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.args.ListDirection</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.List</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.*</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">ListExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">llen</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lmove</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bikes:finished"</span><span class="o">,</span> <span class="n">ListDirection</span><span class="o">.</span><span class="na">LEFT</span><span class="o">,</span> <span class="n">ListDirection</span><span class="o">.</span><span class="na">LEFT</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res13</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:finished"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res14</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res15</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res16</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res16</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:important_bike"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res17</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:important_bike, bike:1, bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res19</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:important_bike"</span><span class="o">,</span> <span class="s">"bike:very_important_bike"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res20</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res21</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res21</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:very_important_bike, bike:important_bike, bike:1, bike:2, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res22</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res22</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res23</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res23</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res24</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res24</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res25</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res25</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res26</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res26</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="mi">2</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res28</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:5, bike:4, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="o">-</span><span class="mi">3</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:3, bike:4, bike:5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res31</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res31</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res32</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span> <span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res32</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; (bikes:repairs, bike:2) </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res33</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res33</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; (bikes:repairs, bike:1) </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res34</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res34</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res35</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">del</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res35</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res36</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">res37</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res37</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">res38</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">type</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res38</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; string </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="k">try</span> <span class="o">{</span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res39</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="o">}</span> <span class="k">catch</span> <span class="o">(</span><span class="n">Exception</span> <span class="n">e</span><span class="o">)</span> <span class="o">{</span> </span></span><span class="line hl"><span class="cl"> <span class="n">e</span><span class="o">.</span><span class="na">printStackTrace</span><span class="o">();</span> </span></span><span class="line hl"><span class="cl"> <span class="c1">// &gt;&gt;&gt; redis.clients.jedis.exceptions.JedisDataException: </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="c1">// &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="o">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res40</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">exists</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res40</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res41</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res41</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res42</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res42</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res43</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res43</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res44</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">exists</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res44</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res45</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">del</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res45</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res46</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">llen</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res46</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res47</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res47</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res48</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res48</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res49</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="mi">2</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res49</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res50</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res50</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:5, bike:4, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_list_tutorial-steprule_1.1')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_list_tutorial-steprule_1.1" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/ListExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_list_tutorial-steprule_1.1" name="list_tutorial-steprule_1.1" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_list_tutorial-steprule_1.1" title="Open example"> Go </label> <div aria-labelledby="tab-list_tutorial-steprule_1.1" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_list_tutorial-steprule_1.1" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_queue</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_stack</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_llen</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lmove_lrange</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LMove</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bikes:finished"</span><span class="p">,</span> <span class="s">"LEFT"</span><span class="p">,</span> <span class="s">"LEFT"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:finished"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lpush_rpush</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:important_bike bike:1 bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_variadic</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">,</span> <span class="s">"bike:very_important_bike"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:very_important_bike bike:important_bike bike:1 bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lpop_rpop</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res22</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res23</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res23</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res24</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res24</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res25</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res25</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res26</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res26</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;empty string&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res27</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res27</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res28</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res28</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res29</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res29</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:5 bike:4 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim_end_of_list</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res30</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res30</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res31</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res31</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res32</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res32</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:3 bike:4 bike:5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_brpop</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res33</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res33</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res34</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res34</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bikes:repairs bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res35</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res35</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bikes:repairs bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res36</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res36</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res37</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Del</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res37</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res38</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res38</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule11</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res39</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res39</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res40</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Type</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res40</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; string </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res41</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="c1">// &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res41</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res42</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res42</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res43</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Exists</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res43</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res44</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res44</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res45</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res45</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res46</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res46</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res47</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Exists</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res47</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule3</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res48</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Del</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res48</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res49</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res49</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res50</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res50</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;empty string&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res51</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res51</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res52</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res52</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res53</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res53</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:5 bike:4 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_list_tutorial-steprule_1.1')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_list_tutorial-steprule_1.1" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/list_tutorial_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_list_tutorial-steprule_1.1" name="list_tutorial-steprule_1.1" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_list_tutorial-steprule_1.1" title="Open example"> C# </label> <div aria-labelledby="tab-list_tutorial-steprule_1.1" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_list_tutorial-steprule_1.1" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">ListExample</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res3</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res4</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res5</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res7</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res8</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLength</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res10</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListMove</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"{bikes}:finished"</span><span class="p">,</span> <span class="n">ListSide</span><span class="p">.</span><span class="n">Left</span><span class="p">,</span> <span class="n">ListSide</span><span class="p">.</span><span class="n">Left</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">Write</span><span class="p">(</span><span class="n">res12</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res13</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"{bikes}:finished"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res14</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res15</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res16</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res17</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res18</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:important_bike, bike:1, bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res19</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:important_bike"</span><span class="p">,</span> <span class="s">"bike:very_important_bike"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res20</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res21</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res21</span><span class="p">));</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; "bike:very_important_bike, bike:important_bike, bike:1, bike:2, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res22</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res22</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res23</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res23</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res24</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res24</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res25</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res25</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res26</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res26</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; &lt;Empty string&gt;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res27</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res27</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res28</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res28</span><span class="p">));</span> <span class="c1">// "bike:5, bike:4, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res29</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res29</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="p">-</span><span class="m">3</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res30</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res30</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:3, bike:4, bike:5"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res31</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res31</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res32</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="p">(</span><span class="n">res32</span> <span class="p">!=</span> <span class="k">null</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"{res32.Item1} -&gt; {res32.Item2}"</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bikes:repairs -&gt; bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res33</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="p">(</span><span class="n">res33</span> <span class="p">!=</span> <span class="k">null</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"{res33.Item1} -&gt; {res33.Item2}"</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bikes:repairs -&gt; bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res34</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res34</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "Null"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res35</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyDelete</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res35</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res36</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res36</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">bool</span> <span class="n">res37</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res37</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisType</span> <span class="n">res38</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyType</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res38</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; RedisType.String</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">try</span> </span></span><span class="line hl"><span class="cl"> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res39</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> <span class="k">catch</span> <span class="p">(</span><span class="n">Exception</span> <span class="n">e</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">e</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res40</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res40</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res41</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExists</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res41</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res42</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res42</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res43</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res43</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res44</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res44</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res45</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExists</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res45</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res46</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyDelete</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res46</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res47</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLength</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res47</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res48</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res48</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; Null</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res49</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res49</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res50</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res50</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:5, bike:4, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_list_tutorial-steprule_1.1')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_list_tutorial-steprule_1.1" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/ListTutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <p> Example of rule 2: </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="list_tutorial-steprule_2"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_list_tutorial-steprule_2" name="list_tutorial-steprule_2" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_list_tutorial-steprule_2" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-list_tutorial-steprule_2" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_list_tutorial-steprule_2" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; RPUSH bikes:repairs bike:1 bike:2 bike:3 </span></span><span class="line hl"><span class="cl">(integer) 3 </span></span><span class="line hl"><span class="cl">&gt; EXISTS bikes:repairs </span></span><span class="line hl"><span class="cl">(integer) 1 </span></span><span class="line hl"><span class="cl">&gt; LPOP bikes:repairs </span></span><span class="line hl"><span class="cl">"bike:3" </span></span><span class="line hl"><span class="cl">&gt; LPOP bikes:repairs </span></span><span class="line hl"><span class="cl">"bike:2" </span></span><span class="line hl"><span class="cl">&gt; LPOP bikes:repairs </span></span><span class="line hl"><span class="cl">"bike:1" </span></span><span class="line hl"><span class="cl">&gt; EXISTS bikes:repairs </span></span><span class="line hl"><span class="cl">(integer) 0</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_list_tutorial-steprule_2')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_list_tutorial-steprule_2" name="list_tutorial-steprule_2" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_list_tutorial-steprule_2" title="Open example"> Python </label> <div aria-labelledby="tab-list_tutorial-steprule_2" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_list_tutorial-steprule_2" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for List doc pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/lists/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">llen</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lmove</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bikes:finished"</span><span class="p">,</span> <span class="s2">"LEFT"</span><span class="p">,</span> <span class="s2">"LEFT"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:1']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:finished"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:2']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:important_bike"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res18</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:important_bike', 'bike:1', 'bike:2']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:important_bike"</span><span class="p">,</span> <span class="s2">"bike:very_important_bike"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="n">res21</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:very_important_bike', 'bike:important_bike', 'bike:1', ...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res22</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res22</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res23</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res23</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:3'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res24</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res24</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:1'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res25</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res25</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res26</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res26</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res28</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res28</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res29</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res29</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:5', 'bike:4', 'bike:3']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res28</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res28</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res29</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res29</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:3', 'bike:4', 'bike:5']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res31</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res31</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res32</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res32</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ('bikes:repairs', 'bike:2')</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res33</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res33</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ('bikes:repairs', 'bike:1')</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res34</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res34</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res35</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res35</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res36</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res36</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res37</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res37</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res38</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">type</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res38</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'string'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">try</span><span class="p">:</span> </span></span><span class="line"><span class="cl"> <span class="n">res39</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1"># &gt;&gt;&gt; redis.exceptions.ResponseError:</span> </span></span><span class="line"><span class="cl"> <span class="c1"># &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value</span> </span></span><span class="line"><span class="cl"><span class="k">except</span> <span class="n">redis</span><span class="o">.</span><span class="n">exceptions</span><span class="o">.</span><span class="n">ResponseError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> </span></span><span class="line"><span class="cl"> <span class="nb">print</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res36</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res40</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res40</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res41</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res41</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:3'</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res42</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res42</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res43</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res43</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:1'</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res44</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res44</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res45</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res45</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res46</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">llen</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res46</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res47</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res47</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res48</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res48</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res49</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res49</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res50</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res50</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:5', 'bike:4', 'bike:3']</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_list_tutorial-steprule_2')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_list_tutorial-steprule_2" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_list.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_list_tutorial-steprule_2" name="list_tutorial-steprule_2" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_list_tutorial-steprule_2" title="Open example"> Node.js </label> <div aria-labelledby="tab-list_tutorial-steprule_2" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_list_tutorial-steprule_2" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">createClient</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">);</span> <span class="c1">// bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">);</span> <span class="c1">// bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">);</span> <span class="c1">// bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">);</span> <span class="c1">// bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lLen</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lMove</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bikes:finished'</span><span class="p">,</span> <span class="s1">'LEFT'</span><span class="p">,</span> <span class="s1">'LEFT'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res13</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res13</span><span class="p">);</span> <span class="c1">// ['bike:1'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:finished'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res14</span><span class="p">);</span> <span class="c1">// ['bike:2'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res15</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res15</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res16</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res16</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res17</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:important_bike'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res17</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res18</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res18</span><span class="p">);</span> <span class="c1">// ['bike:important_bike', 'bike:1', 'bike:2'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res19</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:important_bike'</span><span class="p">,</span> <span class="s1">'bike:very_important_bike'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res20</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res21</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res21</span><span class="p">);</span> <span class="c1">// ['bike:very_important_bike', 'bike:important_bike', 'bike:1', 'bike:2', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res22</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res22</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res23</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res23</span><span class="p">);</span> <span class="c1">// 'bike:3' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res24</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res24</span><span class="p">);</span> <span class="c1">// 'bike:1' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res25</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res25</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res26</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res26</span><span class="p">);</span> <span class="c1">// None </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res27</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res28</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res29</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29</span><span class="p">);</span> <span class="c1">// ['bike:5', 'bike:4', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res27eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27eol</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res28eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28eol</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res29eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29eol</span><span class="p">);</span> <span class="c1">// ['bike:3', 'bike:4', 'bike:5'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res31</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res31</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res32</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res32</span><span class="p">);</span> <span class="c1">// { key: 'bikes:repairs', element: 'bike:2' } </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res33</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res33</span><span class="p">);</span> <span class="c1">// { key: 'bikes:repairs', element: 'bike:1' } </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res34</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res34</span><span class="p">);</span> <span class="c1">// null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res35</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res35</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res36</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res37</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res38</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">type</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res38</span><span class="p">);</span> <span class="c1">// 'string' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="k">try</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kr">const</span> <span class="nx">res39</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// redis.exceptions.ResponseError: </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ErrorReply: WRONGTYPE Operation against a key holding the wrong kind of value] </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="k">catch</span><span class="p">(</span><span class="nx">e</span><span class="p">){</span> </span></span><span class="line"><span class="cl"> <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">e</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res40</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">exists</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res40</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res41</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res41</span><span class="p">);</span> <span class="c1">// 'bike:3' </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res42</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res42</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res43</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res43</span><span class="p">);</span> <span class="c1">// 'bike:1' </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res44</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">exists</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res44</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res45</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res45</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res46</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lLen</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res46</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res47</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res47</span><span class="p">);</span> <span class="c1">// null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res48</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res48</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res49</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res49</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res50</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res50</span><span class="p">);</span> <span class="c1">// ['bike:5', 'bike:4', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_list_tutorial-steprule_2')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_list_tutorial-steprule_2" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-list.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_list_tutorial-steprule_2" name="list_tutorial-steprule_2" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_list_tutorial-steprule_2" title="Open example"> Java </label> <div aria-labelledby="tab-list_tutorial-steprule_2" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_list_tutorial-steprule_2" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nn">io.redis.examples</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.junit.Test</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.args.ListDirection</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.List</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.*</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">ListExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">llen</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lmove</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bikes:finished"</span><span class="o">,</span> <span class="n">ListDirection</span><span class="o">.</span><span class="na">LEFT</span><span class="o">,</span> <span class="n">ListDirection</span><span class="o">.</span><span class="na">LEFT</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res13</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:finished"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res14</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res15</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res16</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res16</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:important_bike"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res17</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:important_bike, bike:1, bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res19</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:important_bike"</span><span class="o">,</span> <span class="s">"bike:very_important_bike"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res20</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res21</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res21</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:very_important_bike, bike:important_bike, bike:1, bike:2, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res22</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res22</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res23</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res23</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res24</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res24</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res25</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res25</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res26</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res26</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="mi">2</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res28</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:5, bike:4, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="o">-</span><span class="mi">3</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:3, bike:4, bike:5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res31</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res31</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res32</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span> <span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res32</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; (bikes:repairs, bike:2) </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res33</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res33</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; (bikes:repairs, bike:1) </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res34</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res34</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res35</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">del</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res35</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res36</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res37</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res37</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res38</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">type</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res38</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; string </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="k">try</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res39</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> <span class="k">catch</span> <span class="o">(</span><span class="n">Exception</span> <span class="n">e</span><span class="o">)</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">e</span><span class="o">.</span><span class="na">printStackTrace</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; redis.clients.jedis.exceptions.JedisDataException: </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="o">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">boolean</span> <span class="n">res40</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">exists</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res40</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">res41</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res41</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">res42</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res42</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">res43</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res43</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">boolean</span> <span class="n">res44</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">exists</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res44</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res45</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">del</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res45</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res46</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">llen</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res46</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res47</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res47</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res48</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res48</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res49</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="mi">2</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res49</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res50</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res50</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:5, bike:4, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_list_tutorial-steprule_2')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_list_tutorial-steprule_2" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/ListExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_list_tutorial-steprule_2" name="list_tutorial-steprule_2" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_list_tutorial-steprule_2" title="Open example"> Go </label> <div aria-labelledby="tab-list_tutorial-steprule_2" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_list_tutorial-steprule_2" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_queue</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_stack</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_llen</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lmove_lrange</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LMove</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bikes:finished"</span><span class="p">,</span> <span class="s">"LEFT"</span><span class="p">,</span> <span class="s">"LEFT"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:finished"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lpush_rpush</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:important_bike bike:1 bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_variadic</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">,</span> <span class="s">"bike:very_important_bike"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:very_important_bike bike:important_bike bike:1 bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lpop_rpop</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res22</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res23</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res23</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res24</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res24</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res25</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res25</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res26</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res26</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;empty string&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res27</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res27</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res28</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res28</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res29</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res29</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:5 bike:4 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim_end_of_list</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res30</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res30</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res31</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res31</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res32</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res32</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:3 bike:4 bike:5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_brpop</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res33</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res33</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res34</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res34</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bikes:repairs bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res35</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res35</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bikes:repairs bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res36</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res36</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res37</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Del</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res37</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res38</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res38</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule11</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res39</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res39</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res40</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Type</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res40</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; string </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res41</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res41</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res42</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res42</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res43</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Exists</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res43</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res44</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res44</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res45</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res45</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res46</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res46</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res47</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Exists</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res47</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule3</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res48</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Del</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res48</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res49</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res49</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res50</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res50</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;empty string&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res51</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res51</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res52</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res52</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res53</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res53</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:5 bike:4 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_list_tutorial-steprule_2')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_list_tutorial-steprule_2" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/list_tutorial_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_list_tutorial-steprule_2" name="list_tutorial-steprule_2" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_list_tutorial-steprule_2" title="Open example"> C# </label> <div aria-labelledby="tab-list_tutorial-steprule_2" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_list_tutorial-steprule_2" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">ListExample</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res3</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res4</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res5</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res7</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res8</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLength</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res10</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListMove</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"{bikes}:finished"</span><span class="p">,</span> <span class="n">ListSide</span><span class="p">.</span><span class="n">Left</span><span class="p">,</span> <span class="n">ListSide</span><span class="p">.</span><span class="n">Left</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">Write</span><span class="p">(</span><span class="n">res12</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res13</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"{bikes}:finished"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res14</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res15</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res16</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res17</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res18</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:important_bike, bike:1, bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res19</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:important_bike"</span><span class="p">,</span> <span class="s">"bike:very_important_bike"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res20</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res21</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res21</span><span class="p">));</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; "bike:very_important_bike, bike:important_bike, bike:1, bike:2, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res22</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res22</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res23</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res23</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res24</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res24</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res25</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res25</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res26</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res26</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; &lt;Empty string&gt;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res27</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res27</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res28</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res28</span><span class="p">));</span> <span class="c1">// "bike:5, bike:4, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res29</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res29</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="p">-</span><span class="m">3</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res30</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res30</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:3, bike:4, bike:5"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res31</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res31</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res32</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="p">(</span><span class="n">res32</span> <span class="p">!=</span> <span class="k">null</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"{res32.Item1} -&gt; {res32.Item2}"</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bikes:repairs -&gt; bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res33</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="p">(</span><span class="n">res33</span> <span class="p">!=</span> <span class="k">null</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"{res33.Item1} -&gt; {res33.Item2}"</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bikes:repairs -&gt; bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res34</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res34</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "Null"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res35</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyDelete</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res35</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res36</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res36</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res37</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res37</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisType</span> <span class="n">res38</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyType</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res38</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; RedisType.String</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">try</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res39</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="k">catch</span> <span class="p">(</span><span class="n">Exception</span> <span class="n">e</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">e</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res40</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res40</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">bool</span> <span class="n">res41</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExists</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res41</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res42</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res42</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:3"</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res43</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res43</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res44</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res44</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">bool</span> <span class="n">res45</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExists</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res45</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res46</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyDelete</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res46</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res47</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLength</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res47</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res48</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res48</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; Null</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res49</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res49</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res50</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res50</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:5, bike:4, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_list_tutorial-steprule_2')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_list_tutorial-steprule_2" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/ListTutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <p> The key no longer exists after all the elements are popped. </p> <p> Example of rule 3: </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="list_tutorial-steprule_3"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_list_tutorial-steprule_3" name="list_tutorial-steprule_3" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_list_tutorial-steprule_3" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-list_tutorial-steprule_3" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_list_tutorial-steprule_3" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; DEL bikes:repairs </span></span><span class="line hl"><span class="cl">(integer) 0 </span></span><span class="line hl"><span class="cl">&gt; LLEN bikes:repairs </span></span><span class="line hl"><span class="cl">(integer) 0 </span></span><span class="line hl"><span class="cl">&gt; LPOP bikes:repairs </span></span><span class="line hl"><span class="cl">(nil)</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_list_tutorial-steprule_3')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_list_tutorial-steprule_3" name="list_tutorial-steprule_3" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_list_tutorial-steprule_3" title="Open example"> Python </label> <div aria-labelledby="tab-list_tutorial-steprule_3" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_list_tutorial-steprule_3" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for List doc pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/lists/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">llen</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lmove</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bikes:finished"</span><span class="p">,</span> <span class="s2">"LEFT"</span><span class="p">,</span> <span class="s2">"LEFT"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:1']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:finished"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:2']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:important_bike"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res18</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:important_bike', 'bike:1', 'bike:2']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:important_bike"</span><span class="p">,</span> <span class="s2">"bike:very_important_bike"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="n">res21</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:very_important_bike', 'bike:important_bike', 'bike:1', ...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res22</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res22</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res23</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res23</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:3'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res24</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res24</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:1'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res25</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res25</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res26</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res26</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res28</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res28</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res29</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res29</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:5', 'bike:4', 'bike:3']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res28</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res28</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res29</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res29</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:3', 'bike:4', 'bike:5']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res31</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">rpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res31</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res32</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res32</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ('bikes:repairs', 'bike:2')</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res33</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res33</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ('bikes:repairs', 'bike:1')</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res34</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">brpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res34</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res35</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res35</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res36</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res36</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res37</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res37</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res38</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">type</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res38</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'string'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">try</span><span class="p">:</span> </span></span><span class="line"><span class="cl"> <span class="n">res39</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"new_bikes"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1"># &gt;&gt;&gt; redis.exceptions.ResponseError:</span> </span></span><span class="line"><span class="cl"> <span class="c1"># &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value</span> </span></span><span class="line"><span class="cl"><span class="k">except</span> <span class="n">redis</span><span class="o">.</span><span class="n">exceptions</span><span class="o">.</span><span class="n">ResponseError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> </span></span><span class="line"><span class="cl"> <span class="nb">print</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res36</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res40</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res40</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res41</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res41</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:3'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res42</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res42</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:2'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res43</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res43</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 'bike:1'</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res44</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res44</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res45</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res45</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res46</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">llen</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res46</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res47</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpop</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res47</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; None</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res48</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lpush</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res48</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res49</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res49</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res50</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">lrange</span><span class="p">(</span><span class="s2">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res50</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['bike:5', 'bike:4', 'bike:3']</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_list_tutorial-steprule_3')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_list_tutorial-steprule_3" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_list.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_list_tutorial-steprule_3" name="list_tutorial-steprule_3" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_list_tutorial-steprule_3" title="Open example"> Node.js </label> <div aria-labelledby="tab-list_tutorial-steprule_3" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_list_tutorial-steprule_3" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">createClient</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">);</span> <span class="c1">// bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">);</span> <span class="c1">// bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">);</span> <span class="c1">// bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">);</span> <span class="c1">// bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lLen</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lMove</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bikes:finished'</span><span class="p">,</span> <span class="s1">'LEFT'</span><span class="p">,</span> <span class="s1">'LEFT'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res13</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res13</span><span class="p">);</span> <span class="c1">// ['bike:1'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:finished'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res14</span><span class="p">);</span> <span class="c1">// ['bike:2'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res15</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res15</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res16</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res16</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res17</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="s1">'bike:important_bike'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res17</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res18</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res18</span><span class="p">);</span> <span class="c1">// ['bike:important_bike', 'bike:1', 'bike:2'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res19</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:important_bike'</span><span class="p">,</span> <span class="s1">'bike:very_important_bike'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res20</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res21</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res21</span><span class="p">);</span> <span class="c1">// ['bike:very_important_bike', 'bike:important_bike', 'bike:1', 'bike:2', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res22</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res22</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res23</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res23</span><span class="p">);</span> <span class="c1">// 'bike:3' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res24</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res24</span><span class="p">);</span> <span class="c1">// 'bike:1' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res25</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res25</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res26</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res26</span><span class="p">);</span> <span class="c1">// None </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res27</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res28</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res29</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29</span><span class="p">);</span> <span class="c1">// ['bike:5', 'bike:4', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res27eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27eol</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res28eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28eol</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res29eol</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29eol</span><span class="p">);</span> <span class="c1">// ['bike:3', 'bike:4', 'bike:5'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res31</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">rPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res31</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res32</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res32</span><span class="p">);</span> <span class="c1">// { key: 'bikes:repairs', element: 'bike:2' } </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res33</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res33</span><span class="p">);</span> <span class="c1">// { key: 'bikes:repairs', element: 'bike:1' } </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res34</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">brPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res34</span><span class="p">);</span> <span class="c1">// null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res35</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res35</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res36</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res37</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res38</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">type</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res38</span><span class="p">);</span> <span class="c1">// 'string' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="k">try</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kr">const</span> <span class="nx">res39</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'new_bikes'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// redis.exceptions.ResponseError: </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ErrorReply: WRONGTYPE Operation against a key holding the wrong kind of value] </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="k">catch</span><span class="p">(</span><span class="nx">e</span><span class="p">){</span> </span></span><span class="line"><span class="cl"> <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">e</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res40</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">exists</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res40</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res41</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res41</span><span class="p">);</span> <span class="c1">// 'bike:3' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res42</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res42</span><span class="p">);</span> <span class="c1">// 'bike:2' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res43</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res43</span><span class="p">);</span> <span class="c1">// 'bike:1' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res44</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">exists</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res44</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res45</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res45</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res46</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lLen</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res46</span><span class="p">);</span> <span class="c1">// 0 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res47</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPop</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res47</span><span class="p">);</span> <span class="c1">// null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res48</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lPush</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res48</span><span class="p">);</span> <span class="c1">// 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res49</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lTrim</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res49</span><span class="p">);</span> <span class="c1">// 'OK' </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res50</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">lRange</span><span class="p">(</span><span class="s1">'bikes:repairs'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res50</span><span class="p">);</span> <span class="c1">// ['bike:5', 'bike:4', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_list_tutorial-steprule_3')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_list_tutorial-steprule_3" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-list.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_list_tutorial-steprule_3" name="list_tutorial-steprule_3" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_list_tutorial-steprule_3" title="Open example"> Java </label> <div aria-labelledby="tab-list_tutorial-steprule_3" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_list_tutorial-steprule_3" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nn">io.redis.examples</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.junit.Test</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.args.ListDirection</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.List</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.*</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">ListExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">llen</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lmove</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bikes:finished"</span><span class="o">,</span> <span class="n">ListDirection</span><span class="o">.</span><span class="na">LEFT</span><span class="o">,</span> <span class="n">ListDirection</span><span class="o">.</span><span class="na">LEFT</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res13</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:finished"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res14</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res15</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res16</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res16</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:important_bike"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res17</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:important_bike, bike:1, bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res19</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:important_bike"</span><span class="o">,</span> <span class="s">"bike:very_important_bike"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res20</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res21</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res21</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:very_important_bike, bike:important_bike, bike:1, bike:2, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res22</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res22</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res23</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res23</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res24</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res24</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res25</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res25</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res26</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res26</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="mi">2</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res28</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:5, bike:4, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="o">-</span><span class="mi">3</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:3, bike:4, bike:5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res31</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">rpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res31</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res32</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span> <span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res32</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; (bikes:repairs, bike:2) </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res33</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res33</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; (bikes:repairs, bike:1) </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res34</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">brpop</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res34</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res35</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">del</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res35</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res36</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res37</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res37</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res38</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">type</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res38</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; string </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="k">try</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res39</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"new_bikes"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> <span class="k">catch</span> <span class="o">(</span><span class="n">Exception</span> <span class="n">e</span><span class="o">)</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">e</span><span class="o">.</span><span class="na">printStackTrace</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; redis.clients.jedis.exceptions.JedisDataException: </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="o">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res40</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">exists</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res40</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res41</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res41</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res42</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res42</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res43</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res43</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res44</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">exists</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res44</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res45</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">del</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res45</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res46</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">llen</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res46</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">res47</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpop</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res47</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; null </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res48</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lpush</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res48</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res49</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ltrim</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="mi">2</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res49</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res50</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">lrange</span><span class="o">(</span><span class="s">"bikes:repairs"</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res50</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:5, bike:4, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_list_tutorial-steprule_3')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_list_tutorial-steprule_3" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/ListExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_list_tutorial-steprule_3" name="list_tutorial-steprule_3" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_list_tutorial-steprule_3" title="Open example"> Go </label> <div aria-labelledby="tab-list_tutorial-steprule_3" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_list_tutorial-steprule_3" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_queue</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_stack</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_llen</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lmove_lrange</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LMove</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bikes:finished"</span><span class="p">,</span> <span class="s">"LEFT"</span><span class="p">,</span> <span class="s">"LEFT"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:finished"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lpush_rpush</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:important_bike bike:1 bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_variadic</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">,</span> <span class="s">"bike:very_important_bike"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:very_important_bike bike:important_bike bike:1 bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_lpop_rpop</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res22</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res23</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res23</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res24</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res24</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res25</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res25</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res26</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res26</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;empty string&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res27</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res27</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res28</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res28</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res29</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res29</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:5 bike:4 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim_end_of_list</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res30</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res30</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res31</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res31</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res32</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res32</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:3 bike:4 bike:5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_brpop</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res33</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">RPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res33</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res34</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res34</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bikes:repairs bike:2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res35</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res35</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bikes:repairs bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res36</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">BRPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res36</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res37</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Del</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res37</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res38</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res38</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule11</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res39</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res39</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res40</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Type</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res40</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; string </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res41</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; WRONGTYPE Operation against a key holding the wrong kind of value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res41</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res42</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res42</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res43</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Exists</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res43</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res44</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res44</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res45</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res45</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res46</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res46</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res47</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Exists</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res47</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_rule3</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res48</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Del</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res48</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res49</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res49</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res50</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; redis: nil </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res50</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;empty string&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ltrim1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res51</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LPush</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res51</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 5 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res52</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LTrim</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res52</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res53</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">LRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res53</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:5 bike:4 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_list_tutorial-steprule_3')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_list_tutorial-steprule_3" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/list_tutorial_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_list_tutorial-steprule_3" name="list_tutorial-steprule_3" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_list_tutorial-steprule_3" title="Open example"> C# </label> <div aria-labelledby="tab-list_tutorial-steprule_3" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_list_tutorial-steprule_3" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">ListExample</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res3</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res4</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res5</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res7</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res8</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLength</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res10</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListMove</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="s">"{bikes}:finished"</span><span class="p">,</span> <span class="n">ListSide</span><span class="p">.</span><span class="n">Left</span><span class="p">,</span> <span class="n">ListSide</span><span class="p">.</span><span class="n">Left</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">Write</span><span class="p">(</span><span class="n">res12</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"{bikes}:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res13</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"{bikes}:finished"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res14</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res15</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res16</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="s">"bike:important_bike"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res17</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res18</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:important_bike, bike:1, bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res19</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:important_bike"</span><span class="p">,</span> <span class="s">"bike:very_important_bike"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res20</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res21</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res21</span><span class="p">));</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; "bike:very_important_bike, bike:important_bike, bike:1, bike:2, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res22</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res22</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res23</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res23</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res24</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res24</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res25</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res25</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res26</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res26</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; &lt;Empty string&gt;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res27</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res27</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res28</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res28</span><span class="p">));</span> <span class="c1">// "bike:5, bike:4, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res29</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res29</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="p">-</span><span class="m">3</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res30</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res30</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:3, bike:4, bike:5"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res31</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res31</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res32</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="p">(</span><span class="n">res32</span> <span class="p">!=</span> <span class="k">null</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"{res32.Item1} -&gt; {res32.Item2}"</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bikes:repairs -&gt; bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res33</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="p">(</span><span class="n">res33</span> <span class="p">!=</span> <span class="k">null</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"{res33.Item1} -&gt; {res33.Item2}"</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bikes:repairs -&gt; bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Tuple</span><span class="p">&lt;</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">&gt;?</span> <span class="n">res34</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BRPop</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bikes:repairs"</span> <span class="p">},</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res34</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "Null"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res35</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyDelete</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res35</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res36</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res36</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res37</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res37</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisType</span> <span class="n">res38</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyType</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res38</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; RedisType.String</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">try</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res39</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRightPush</span><span class="p">(</span><span class="s">"new_bikes"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="k">catch</span> <span class="p">(</span><span class="n">Exception</span> <span class="n">e</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">e</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res40</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res40</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res41</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExists</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res41</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res42</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res42</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res43</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res43</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:2"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res44</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res44</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; "bike:1"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res45</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExists</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res45</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">bool</span> <span class="n">res46</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyDelete</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res46</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res47</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLength</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res47</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res48</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPop</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res48</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; Null</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res49</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListLeftPush</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res49</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">ListTrim</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res50</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">ListRange</span><span class="p">(</span><span class="s">"bikes:repairs"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res50</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "bike:5, bike:4, bike:3"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_list_tutorial-steprule_3')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_list_tutorial-steprule_3" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/ListTutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <h2 id="limits"> Limits </h2> <p> The max length of a Redis list is 2^32 - 1 (4,294,967,295) elements. </p> <h2 id="performance"> Performance </h2> <p> List operations that access its head or tail are O(1), which means they're highly efficient. However, commands that manipulate elements within a list are usually O(n). Examples of these include <a href="/docs/latest/commands/lindex/"> <code> LINDEX </code> </a> , <a href="/docs/latest/commands/linsert/"> <code> LINSERT </code> </a> , and <a href="/docs/latest/commands/lset/"> <code> LSET </code> </a> . Exercise caution when running these commands, mainly when operating on large lists. </p> <h2 id="alternatives"> Alternatives </h2> <p> Consider <a href="/docs/latest/develop/data-types/streams/"> Redis streams </a> as an alternative to lists when you need to store and process an indeterminate series of events. </p> <h2 id="learn-more"> Learn more </h2> <ul> <li> <a href="https://www.youtube.com/watch?v=PB5SeOkkxQc"> Redis Lists Explained </a> is a short, comprehensive video explainer on Redis lists. </li> <li> <a href="https://university.redis.com/courses/ru101/"> Redis University's RU101 </a> covers Redis lists in detail. </li> </ul> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/develop/data-types/lists/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/develop/interact/search-and-query/advanced-concepts/escaping/.html
<section class="prose w-full py-12"> <h1> Tokenization </h1> <p class="text-lg -mt-5 mb-10"> Controlling text tokenization and escaping </p> <p> Full-text search works by comparing words, URLs, numbers, and other elements of the query against the text in the searchable fields of each document. However, it would be very inefficient to compare the entire text of the query against the entire text of each field over and over again, so the search system doesn't do this. Instead, it splits the document text into short, significant sections called <em> tokens </em> during the indexing process and stores the tokens as part of the document's index data. </p> <p> During a search, the query system also tokenizes the query text and then simply compares the tokens from the query against the tokens stored for each document. Finding a match like this is much more efficient than pattern-matching on the whole text and also lets you use <a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/stemming/"> stemming </a> and <a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/stopwords/"> stop words </a> to improve the search even further. See this article about <a href="https://queryunderstanding.com/tokenization-c8cdd6aef7ff"> Tokenization </a> for a general introduction to the concepts. </p> <p> Redis Stack uses a very simple tokenizer for documents and a slightly more sophisticated tokenizer for queries. Both allow a degree of control over string escaping and tokenization. </p> <p> The sections below describe the rules for tokenizing text fields and queries. Note that <a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/tags/"> Tag fields </a> are essentially text fields but they use a simpler form of tokenization, as described separately in the <a href="#tokenization-rules-for-tag-fields"> Tokenization rules for tag fields </a> section. </p> <h2 id="tokenization-rules-for-text-fields"> Tokenization rules for text fields </h2> <ol> <li> <p> All punctuation marks and whitespace (besides underscores) separate the document and queries into tokens. For example, any character of <code> ,.&lt;&gt;{}[]"':;!@#$%^&amp;*()-+=~ </code> will break the text into terms, so the text <code> foo-bar.baz...bag </code> will be tokenized into <code> [foo, bar, baz, bag] </code> </p> </li> <li> <p> Escaping separators in both queries and documents is done by prepending a backslash to any separator. For example, the text <code> hello\-world hello-world </code> will be tokenized as <code> [hello-world, hello, world] </code> . In most languages you will need an extra backslash to signify an actual backslash when formatting the document or query, so the actual text entered into redis-cli will be <code> hello\\-world </code> . </p> </li> <li> <p> Underscores ( <code> _ </code> ) are not used as separators in either document or query, so the text <code> hello_world </code> will remain as is after tokenization. </p> </li> <li> <p> Repeating spaces or punctuation marks are stripped. </p> </li> <li> <p> Latin characters are converted to lowercase. </p> </li> <li> <p> A backslash before the first digit will tokenize it as a term. This will translate the <code> - </code> sign as NOT, which otherwise would make the number negative. Add a backslash before <code> . </code> if you are searching for a float. For example, <code> -20 -&gt; {-20} vs -\20 -&gt; {NOT{20}} </code> . </p> </li> </ol> <h2 id="tokenization-rules-for-tag-fields"> Tokenization rules for tag fields </h2> <p> <a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/tags/"> Tag fields </a> interpret a text field as a list of <em> tags </em> delimited by a <a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/tags/#creating-a-tag-field"> separator </a> character (which is a comma "," by default). The tokenizer simply splits the text wherever it finds the separator and so most punctuation marks and whitespace are valid characters within each tag token. The only changes that the tokenizer makes to the tags are: </p> <ul> <li> Trimming whitespace at the start and end of the tag. Other whitespace in the tag text is left intact. </li> <li> Converting Latin alphabet characters to lowercase. You can override this by adding the <a href="/docs/latest/develop/interact/search-and-query/basic-constructs/field-and-type-options/#tag-fields"> <code> CASESENSITIVE </code> </a> option in the indexing schema for the tag field. </li> </ul> <p> This means that when you define a tag field, you don't need to escape any characters, except in the unusual case where you want leading or trailing spaces to be part of the tag text. However, you do need to escape certain characters in a <em> query </em> against a tag field. See <a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/query_syntax/#tag-filters"> Query syntax </a> for more information about this. </p> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/develop/interact/search-and-query/advanced-concepts/escaping/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/integrate/write-behind/data-transformation/transformation-examples/write-behind-to-redis-example/.html
<section class="prose w-full py-12 max-w-none"> <h1> Write-behind to Redis Enterprise target example </h1> <p> The <code> redis.write </code> block can be used in the <code> output </code> section of the write-behind job in order to enable writing data to the Redis Enterprise target database. Multiple blocks can be used at the same time to write data to different data types. The following example captures data modified in the <code> address:* </code> keyspace, then creates a new JSON-like string field named <code> json_addr </code> , and, finally, writes the results to multiple keys in target Redis Enteprise database: </p> <div class="highlight"> <pre class="chroma"><code class="language-yaml" data-lang="yaml"><span class="line"><span class="cl"><span class="nt">source</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">redis</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">trigger</span><span class="p">:</span><span class="w"> </span><span class="l">write-behind</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">key_pattern</span><span class="p">:</span><span class="w"> </span><span class="l">address:*</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">transform</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">uses</span><span class="p">:</span><span class="w"> </span><span class="l">add_field</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">with</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">fields</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">field</span><span class="p">:</span><span class="w"> </span><span class="s2">"json_addr"</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">expression</span><span class="p">:</span><span class="w"> </span><span class="l">concat(['{"city":', city, ', "zip":', zip, '}'])</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">language</span><span class="p">:</span><span class="w"> </span><span class="l">jmespath</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">output</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">uses</span><span class="p">:</span><span class="w"> </span><span class="l">redis.write</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">with</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">data_type</span><span class="p">:</span><span class="w"> </span><span class="l">hash</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">connection</span><span class="p">:</span><span class="w"> </span><span class="l">target</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">key</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">expression</span><span class="p">:</span><span class="w"> </span><span class="l">concat(['addr:org_id:', org_id, ':hash'])</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">language</span><span class="p">:</span><span class="w"> </span><span class="l">jmespath</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">uses</span><span class="p">:</span><span class="w"> </span><span class="l">redis.write</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">with</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">data_type</span><span class="p">:</span><span class="w"> </span><span class="l">json</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">key</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">expression</span><span class="p">:</span><span class="w"> </span><span class="l">concat(['addr:org_id:', org_id, ':json'])</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">language</span><span class="p">:</span><span class="w"> </span><span class="l">jmespath</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">on_update</span><span class="p">:</span><span class="w"> </span><span class="l">merge</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">uses</span><span class="p">:</span><span class="w"> </span><span class="l">redis.write</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">with</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">data_type</span><span class="p">:</span><span class="w"> </span><span class="l">set</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">key</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">expression</span><span class="p">:</span><span class="w"> </span><span class="l">concat(['addresses:', country])</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">language</span><span class="p">:</span><span class="w"> </span><span class="l">jmespath</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">args</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">member</span><span class="p">:</span><span class="w"> </span><span class="l">json_addr</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">uses</span><span class="p">:</span><span class="w"> </span><span class="l">redis.write</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">with</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">data_type</span><span class="p">:</span><span class="w"> </span><span class="l">sorted_set</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">key</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">expression</span><span class="p">:</span><span class="w"> </span><span class="l">concat(['addrs_withscores:', country])</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">language</span><span class="p">:</span><span class="w"> </span><span class="l">jmespath</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">args</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">score</span><span class="p">:</span><span class="w"> </span><span class="l">zip</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">member</span><span class="p">:</span><span class="w"> </span><span class="l">json_addr</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">uses</span><span class="p">:</span><span class="w"> </span><span class="l">redis.write</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">with</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">data_type</span><span class="p">:</span><span class="w"> </span><span class="l">stream</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">key</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">expression</span><span class="p">:</span><span class="w"> </span><span class="s2">"`addresses:events`"</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">language</span><span class="p">:</span><span class="w"> </span><span class="l">jmespath</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">mapping</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">org_id</span><span class="p">:</span><span class="w"> </span><span class="l">message_id</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">zip</span><span class="p">:</span><span class="w"> </span><span class="l">zip_code</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="l">country</span><span class="w"> </span></span></span></code></pre> </div> <p> Run the following command in the source Redis Enterprise database to test the job: </p> <div class="highlight"> <pre class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">127.0.0.1:12005&gt; hset address:1 city Austin zip <span class="m">78901</span> org_id <span class="m">1</span> country USA </span></span></code></pre> </div> <p> The result is five keys will be created in the target Redis Enterprise database (hash, JSON, set, sorted set, and stream): </p> <div class="highlight"> <pre class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">127.0.0.1:12000&gt; keys * </span></span><span class="line"><span class="cl">1<span class="o">)</span> <span class="s2">"addr:org_id:1:hash"</span> </span></span><span class="line"><span class="cl">2<span class="o">)</span> <span class="s2">"addr:org_id:1:json"</span> </span></span><span class="line"><span class="cl">3<span class="o">)</span> <span class="s2">"addresses:USA"</span> </span></span><span class="line"><span class="cl">4<span class="o">)</span> <span class="s2">"addrs_withscores:USA"</span> </span></span><span class="line"><span class="cl">5<span class="o">)</span> <span class="s2">"addresses:events"</span> </span></span></code></pre> </div> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/integrate/write-behind/data-transformation/transformation-examples/write-behind-to-redis-example/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/gears-v1/jvm/classes/gearsbuilder/callnextarray/.html
<section class="prose w-full py-12 max-w-none"> <h1> CallNextArray </h1> <p class="text-lg -mt-5 mb-10"> Calls the next execution that overrides the command or the original command itself. </p> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">static</span> <span class="kd">native</span> <span class="n">java</span><span class="o">.</span><span class="na">lang</span><span class="o">.</span><span class="na">Object</span> <span class="nf">callNextArray</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="n">java</span><span class="o">.</span><span class="na">lang</span><span class="o">.</span><span class="na">String</span><span class="o">[]</span> <span class="n">command</span><span class="o">)</span> </span></span></code></pre> </div> <p> When you override a Redis command with the <a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/gears-v1/jvm/classes/readers/commandoverrider/"> <code> CommandOverrider </code> </a> , use <code> callNextArray </code> to run the next execution that overrides the command or the original command itself. </p> <p> It accepts an array of strings, which represents the command arguments. </p> <h2 id="parameters"> Parameters </h2> <table> <thead> <tr> <th> Name </th> <th> Type </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> args </td> <td> array of strings </td> <td> Redis command arguments </td> </tr> </tbody> </table> <h2 id="returns"> Returns </h2> <p> Returns the command result. It could be a string or an array of strings, depending on the command. </p> <h2 id="example"> Example </h2> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="n">GearsBuilder</span><span class="o">.</span><span class="na">callNextArray</span><span class="o">(</span><span class="k">new</span> <span class="n">String</span><span class="o">[]{</span><span class="s">"restaurant:1"</span><span class="o">,</span> <span class="s">"reviews"</span><span class="o">,</span> <span class="s">"50"</span><span class="o">});</span> </span></span></code></pre> </div> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/gears-v1/jvm/classes/gearsbuilder/callnextarray/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/references/cli-utilities/rlcheck/.html
<section class="prose w-full py-12 max-w-none"> <h1> rlcheck </h1> <p class="text-lg -mt-5 mb-10"> Verify nodes. </p> <p> The <code> rlcheck </code> utility runs various <a href="#tests"> tests </a> to check the health of a Redis Enterprise Software node and reports any discovered issues. You can use this utility to confirm a successful installation or to verify that the node is functioning properly. </p> <p> To resolve issues reported by <code> rlcheck </code> , <a href="https://redis.com/company/support/"> contact Redis support </a> . </p> <h2 id="run-rlcheck"> Run rlcheck </h2> <p> You can run <code> rlcheck </code> from the node host's command line. The output of <code> rlcheck </code> shows information specific to the host you run it on. </p> <p> To run <code> rlcheck </code> tests: </p> <ol> <li> <p> Sign in to the Redis Enterprise Software host with an account that is a member of the <strong> redislabs </strong> operating system group. </p> </li> <li> <p> Run: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rlcheck </span></span></code></pre> </div> </li> </ol> <h2 id="options"> Options </h2> <p> You can run <code> rlcheck </code> with the following options: </p> <table> <thead> <tr> <th> Option </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <nobr> <code> --suppress-tests TEXT </code> </nobr> </td> <td> Skip the specified, comma-delimited list of tests. See <a href="#tests"> Tests </a> for the list of tests and descriptions. </td> </tr> <tr> <td> <nobr> <code> --retry-delay INTEGER </code> </nobr> </td> <td> Delay between retries, in seconds. </td> </tr> <tr> <td> <nobr> <code> --retry INTEGER </code> </nobr> </td> <td> Number of retries after a failure. </td> </tr> <tr> <td> <nobr> <code> --file-path TEXT </code> </nobr> </td> <td> Custom path to <code> rlcheck.log </code> . </td> </tr> <tr> <td> <nobr> <code> --continue-on-error </code> </nobr> </td> <td> Continue to run all tests even if a test fails, then show all errors when complete. </td> </tr> <tr> <td> <code> --help </code> </td> <td> Return the list of <code> rlcheck </code> options. </td> </tr> </tbody> </table> <h2 id="tests"> Tests </h2> <p> <code> rlcheck </code> runs the following tests by default: </p> <table> <thead> <tr> <th> Test name </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> verify_owner_and_group </td> <td> Verifies the owner and group for Redis Enterprise Software files are correct. </td> </tr> <tr> <td> verify_bootstrap_status </td> <td> Verifies the local node's bootstrap process completed without errors. </td> </tr> <tr> <td> verify_services </td> <td> Verifies all Redis Enterprise Software services are running. </td> </tr> <tr> <td> verify_port_range </td> <td> Verifies the <a href="https://www.kernel.org/doc/html/latest/networking/ip-sysctl.html"> <code> ip_local_port_range </code> </a> doesn't conflict with the ports Redis Enterprise might assign to shards. </td> </tr> <tr> <td> verify_pidfiles </td> <td> Verifies all active local shards have PID files. </td> </tr> <tr> <td> verify_capabilities </td> <td> Verifies all binaries have the proper capability bits. </td> </tr> <tr> <td> verify_existing_sockets </td> <td> Verifies sockets exist for all processes that require them. </td> </tr> <tr> <td> verify_host_settings </td> <td> Verifies the following: <br/> • Linux <code> overcommit_memory </code> setting is 1. <br/> • <code> transparent_hugepage </code> is disabled. <br/> • Socket maximum connections setting <code> somaxconn </code> is 1024. </td> </tr> <tr> <td> verify_tcp_connectivity </td> <td> Verifies this node can connect to all other alive nodes. </td> </tr> <tr> <td> verify_encrypted_gossip </td> <td> Verifies gossip communication is encrypted. </td> </tr> </tbody> </table> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/references/cli-utilities/rlcheck/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/references/cli-utilities/rladmin/migrate/.html
<section class="prose w-full py-12 max-w-none"> <h1> rladmin migrate </h1> <p class="text-lg -mt-5 mb-10"> Moves Redis Enterprise Software shards or endpoints to a new node in the same cluster. </p> <p> Moves Redis Enterprise shards or endpoints to a new node in the same cluster. </p> <p> For more information about shard migration use cases and considerations, see <a href="/docs/latest/operate/rs/databases/migrate-shards/"> Migrate database shards </a> . </p> <h2 id="migrate-all_master_shards"> <code> migrate all_master_shards </code> </h2> <p> Moves all primary shards of a specified database or node to a new node in the same cluster. </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin migrate <span class="o">{</span> db <span class="o">{</span> db:&lt;id&gt; <span class="p">|</span> &lt;name&gt; <span class="o">}</span> <span class="p">|</span> node &lt;origin node ID&gt; <span class="o">}</span> </span></span><span class="line"><span class="cl"> all_master_shards </span></span><span class="line"><span class="cl"> target_node &lt;id&gt; </span></span><span class="line"><span class="cl"> <span class="o">[</span> override_policy <span class="o">]</span> </span></span></code></pre> </div> <h3 id="parameters"> Parameters </h3> <table> <thead> <tr> <th> Parameter </th> <th> Type/Value </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> db </td> <td> db:&lt;id&gt; <br/> name </td> <td> Limits migration to a specific database </td> </tr> <tr> <td> node </td> <td> integer </td> <td> Limits migration to a specific origin node </td> </tr> <tr> <td> target_node </td> <td> integer </td> <td> Migration target node </td> </tr> <tr> <td> override_policy </td> <td> </td> <td> Overrides the rack aware policy and allows primary and replica shards on the same node </td> </tr> </tbody> </table> <h3 id="returns"> Returns </h3> <p> Returns <code> Done </code> if the migration completed successfully. Otherwise, returns an error. </p> <p> Use <a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/status/#status-shards"> <code> rladmin status shards </code> </a> to verify the migration completed. </p> <h3 id="example"> Example </h3> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ rladmin status shards db db:6 sort ROLE </span></span><span class="line"><span class="cl">SHARDS: </span></span><span class="line"><span class="cl">DB:ID NAME ID NODE ROLE SLOTS USED_MEMORY STATUS </span></span><span class="line"><span class="cl">db:6 tr02 redis:14 node:3 master 0-4095 3.01MB OK </span></span><span class="line"><span class="cl">db:6 tr02 redis:16 node:3 master 4096-8191 3.2MB OK </span></span><span class="line"><span class="cl">db:6 tr02 redis:18 node:3 master 8192-12287 3.2MB OK </span></span><span class="line"><span class="cl">db:6 tr02 redis:20 node:3 master 12288-16383 3.01MB OK </span></span><span class="line"><span class="cl">$ rladmin migrate db db:6 all_master_shards target_node <span class="m">1</span> </span></span><span class="line"><span class="cl">Monitoring 8b0f28e2-4342-427a-a8e3-a68cba653ffe </span></span><span class="line"><span class="cl">queued - migrate_shards </span></span><span class="line"><span class="cl">running - migrate_shards </span></span><span class="line"><span class="cl">Executing migrate_redis with shards_uids <span class="o">[</span><span class="s1">'18'</span>, <span class="s1">'14'</span>, <span class="s1">'20'</span>, <span class="s1">'16'</span><span class="o">]</span> </span></span><span class="line"><span class="cl">Ocompleted - migrate_shards </span></span><span class="line"><span class="cl">Done </span></span><span class="line"><span class="cl">$ rladmin status shards node <span class="m">1</span> </span></span><span class="line"><span class="cl">SHARDS: </span></span><span class="line"><span class="cl">DB:ID NAME ID NODE ROLE SLOTS USED_MEMORY STATUS </span></span><span class="line"><span class="cl">db:6 tr02 redis:14 node:1 master 0-4095 3.22MB OK </span></span><span class="line"><span class="cl">db:6 tr02 redis:16 node:1 master 4096-8191 3.22MB OK </span></span><span class="line"><span class="cl">db:6 tr02 redis:18 node:1 master 8192-12287 3.22MB OK </span></span><span class="line"><span class="cl">db:6 tr02 redis:20 node:1 master 12288-16383 2.99MB OK </span></span></code></pre> </div> <h2 id="migrate-all_shards"> <code> migrate all_shards </code> </h2> <p> Moves all shards on a specified node to a new node in the same cluster. </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin migrate node &lt;origin node ID&gt; </span></span><span class="line"><span class="cl"> <span class="o">[</span> max_concurrent_bdb_migrations &lt;value&gt; <span class="o">]</span> </span></span><span class="line"><span class="cl"> all_shards </span></span><span class="line"><span class="cl"> target_node &lt;id&gt; </span></span><span class="line"><span class="cl"> <span class="o">[</span> override_policy <span class="o">]</span> </span></span></code></pre> </div> <h3 id="parameters-1"> Parameters </h3> <table> <thead> <tr> <th> Parameter </th> <th> Type/Value </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> node </td> <td> integer </td> <td> Limits migration to a specific origin node </td> </tr> <tr> <td> max_concurrent_bdb_migrations </td> <td> integer </td> <td> Sets the maximum number of concurrent endpoint migrations </td> </tr> <tr> <td> override_policy </td> <td> </td> <td> Overrides the rack aware policy and allows primary and replica shards on the same node </td> </tr> </tbody> </table> <h3 id="returns-1"> Returns </h3> <p> Returns <code> Done </code> if the migration completed successfully. Otherwise, returns an error. </p> <p> Use <a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/status/#status-shards"> <code> rladmin status shards </code> </a> to verify the migration completed. </p> <h3 id="example-1"> Example </h3> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ rladmin status shards node <span class="m">1</span> </span></span><span class="line"><span class="cl">SHARDS: </span></span><span class="line"><span class="cl">DB:ID NAME ID NODE ROLE SLOTS USED_MEMORY STATUS </span></span><span class="line"><span class="cl">db:5 tr01 redis:12 node:1 master 0-16383 3.04MB OK </span></span><span class="line"><span class="cl">db:6 tr02 redis:15 node:1 slave 0-4095 2.93MB OK </span></span><span class="line"><span class="cl">db:6 tr02 redis:17 node:1 slave 4096-8191 2.93MB OK </span></span><span class="line"><span class="cl">db:6 tr02 redis:19 node:1 slave 8192-12287 3.08MB OK </span></span><span class="line"><span class="cl">db:6 tr02 redis:21 node:1 slave 12288-16383 3.08MB OK </span></span><span class="line"><span class="cl">$ rladmin migrate node <span class="m">1</span> all_shards target_node <span class="m">2</span> </span></span><span class="line"><span class="cl">Monitoring 71a4f371-9264-4398-a454-ce3ff4858c09 </span></span><span class="line"><span class="cl">queued - migrate_shards </span></span><span class="line"><span class="cl">.running - migrate_shards </span></span><span class="line"><span class="cl">Executing migrate_redis with shards_uids <span class="o">[</span><span class="s1">'21'</span>, <span class="s1">'15'</span>, <span class="s1">'17'</span>, <span class="s1">'19'</span><span class="o">]</span> </span></span><span class="line"><span class="cl">OExecuting migrate_redis with shards_uids <span class="o">[</span><span class="s1">'12'</span><span class="o">]</span> </span></span><span class="line"><span class="cl">Ocompleted - migrate_shards </span></span><span class="line"><span class="cl">Done </span></span><span class="line"><span class="cl">$ rladmin status shards node <span class="m">2</span> </span></span><span class="line"><span class="cl">SHARDS: </span></span><span class="line"><span class="cl">DB:ID NAME ID NODE ROLE SLOTS USED_MEMORY STATUS </span></span><span class="line"><span class="cl">db:5 tr01 redis:12 node:2 master 0-16383 3.14MB OK </span></span><span class="line"><span class="cl">db:6 tr02 redis:15 node:2 slave 0-4095 2.96MB OK </span></span><span class="line"><span class="cl">db:6 tr02 redis:17 node:2 slave 4096-8191 2.96MB OK </span></span><span class="line"><span class="cl">db:6 tr02 redis:19 node:2 slave 8192-12287 2.96MB OK </span></span><span class="line"><span class="cl">db:6 tr02 redis:21 node:2 slave 12288-16383 2.96MB OK </span></span></code></pre> </div> <h2 id="migrate-all_slave_shards"> <code> migrate all_slave_shards </code> </h2> <p> Moves all replica shards of a specified database or node to a new node in the same cluster. </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin migrate <span class="o">{</span> db <span class="o">{</span> db:&lt;id&gt; <span class="p">|</span> &lt;name&gt; <span class="o">}</span> <span class="p">|</span> node &lt;origin node ID&gt; <span class="o">}</span> </span></span><span class="line"><span class="cl"> all_slave_shards </span></span><span class="line"><span class="cl"> target_node &lt;id&gt; </span></span><span class="line"><span class="cl"> <span class="o">[</span> override_policy <span class="o">]</span> </span></span></code></pre> </div> <h3 id="parameters-2"> Parameters </h3> <table> <thead> <tr> <th> Parameter </th> <th> Type/Value </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> db </td> <td> db:&lt;id&gt; <br/> name </td> <td> Limits migration to a specific database </td> </tr> <tr> <td> node </td> <td> integer </td> <td> Limits migration to a specific origin node </td> </tr> <tr> <td> target_node </td> <td> integer </td> <td> Migration target node </td> </tr> <tr> <td> override_policy </td> <td> </td> <td> Overrides the rack aware policy and allows primary and replica shards on the same node </td> </tr> </tbody> </table> <h3 id="returns-2"> Returns </h3> <p> Returns <code> Done </code> if the migration completed successfully. Otherwise, returns an error. </p> <p> Use <a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/status/#status-shards"> <code> rladmin status shards </code> </a> to verify the migration completed. </p> <h3 id="example-2"> Example </h3> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ rladmin status shards db db:6 node <span class="m">2</span> </span></span><span class="line"><span class="cl">SHARDS: </span></span><span class="line"><span class="cl">DB:ID NAME ID NODE ROLE SLOTS USED_MEMORY STATUS </span></span><span class="line"><span class="cl">db:6 tr02 redis:15 node:2 slave 0-4095 3.06MB OK </span></span><span class="line"><span class="cl">db:6 tr02 redis:17 node:2 slave 4096-8191 3.06MB OK </span></span><span class="line"><span class="cl">db:6 tr02 redis:19 node:2 slave 8192-12287 3.06MB OK </span></span><span class="line"><span class="cl">db:6 tr02 redis:21 node:2 slave 12288-16383 3.06MB OK </span></span><span class="line"><span class="cl">$ rladmin migrate db db:6 all_slave_shards target_node <span class="m">3</span> </span></span><span class="line"><span class="cl">Monitoring 5d36a98c-3dc8-435f-8ed9-35809ba017a4 </span></span><span class="line"><span class="cl">queued - migrate_shards </span></span><span class="line"><span class="cl">.running - migrate_shards </span></span><span class="line"><span class="cl">Executing migrate_redis with shards_uids <span class="o">[</span><span class="s1">'15'</span>, <span class="s1">'17'</span>, <span class="s1">'21'</span>, <span class="s1">'19'</span><span class="o">]</span> </span></span><span class="line"><span class="cl">Ocompleted - migrate_shards </span></span><span class="line"><span class="cl">Done </span></span><span class="line"><span class="cl">$ rladmin status shards db db:6 node <span class="m">3</span> </span></span><span class="line"><span class="cl">SHARDS: </span></span><span class="line"><span class="cl">DB:ID NAME ID NODE ROLE SLOTS USED_MEMORY STATUS </span></span><span class="line"><span class="cl">db:6 tr02 redis:15 node:3 slave 0-4095 3.04MB OK </span></span><span class="line"><span class="cl">db:6 tr02 redis:17 node:3 slave 4096-8191 3.04MB OK </span></span><span class="line"><span class="cl">db:6 tr02 redis:19 node:3 slave 8192-12287 3.04MB OK </span></span><span class="line"><span class="cl">db:6 tr02 redis:21 node:3 slave 12288-16383 3.04MB OK </span></span></code></pre> </div> <h2 id="migrate-endpoint_to_shards"> <code> migrate endpoint_to_shards </code> </h2> <p> Moves database endpoints to the node where the majority of primary shards are located. </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin migrate <span class="o">[</span> db <span class="o">{</span> db:&lt;id&gt; <span class="p">|</span> &lt;name&gt; <span class="o">}</span> <span class="o">]</span> </span></span><span class="line"><span class="cl"> endpoint_to_shards </span></span><span class="line"><span class="cl"> <span class="o">[</span> restrict_target_node &lt;id&gt; <span class="o">]</span> </span></span><span class="line"><span class="cl"> <span class="o">[</span> commit <span class="o">]</span> </span></span><span class="line"><span class="cl"> <span class="o">[</span> max_concurrent_bdb_migrations &lt;value&gt; <span class="o">]</span> </span></span></code></pre> </div> <h3 id="parameters-3"> Parameters </h3> <table> <thead> <tr> <th> Parameter </th> <th> Type/Value </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> db </td> <td> db:&lt;id&gt; <br/> name </td> <td> Limits migration to a specific database </td> </tr> <tr> <td> restrict_target_node </td> <td> integer </td> <td> Moves the endpoint only if the target node matches the specified node </td> </tr> <tr> <td> commit </td> <td> </td> <td> Performs endpoint movement </td> </tr> <tr> <td> max_concurrent_bdb_migrations </td> <td> integer </td> <td> Sets the maximum number of concurrent endpoint migrations </td> </tr> </tbody> </table> <h3 id="returns-3"> Returns </h3> <p> Returns a list of steps to perform the migration. If the <code> commit </code> flag is set, the steps will run and return <code> Finished successfully </code> if they were completed. Otherwise, returns an error. </p> <p> Use <a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/status/#status-endpoints"> <code> rladmin status endpoints </code> </a> to verify that the endpoints were moved. </p> <h3 id="example-3"> Example </h3> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ rladmin status endpoints db db:6 </span></span><span class="line"><span class="cl">ENDPOINTS: </span></span><span class="line"><span class="cl">DB:ID NAME ID NODE ROLE SSL </span></span><span class="line"><span class="cl">db:6 tr02 endpoint:6:1 node:3 all-master-shards No </span></span><span class="line"><span class="cl">$ rladmin migrate db db:6 endpoint_to_shards </span></span><span class="line"><span class="cl">* Going to <span class="nb">bind</span> endpoint:6:1 to node <span class="m">1</span> </span></span><span class="line"><span class="cl">Dry-run completed, add <span class="s1">'commit'</span> argument to execute </span></span><span class="line"><span class="cl">$ rladmin migrate db db:6 endpoint_to_shards commit </span></span><span class="line"><span class="cl">* Going to <span class="nb">bind</span> endpoint:6:1 to node <span class="m">1</span> </span></span><span class="line"><span class="cl">Executing <span class="nb">bind</span> endpoint:6:1: OOO. </span></span><span class="line"><span class="cl">Finished successfully </span></span><span class="line"><span class="cl">$ rladmin status endpoints db db:6 </span></span><span class="line"><span class="cl">ENDPOINTS: </span></span><span class="line"><span class="cl">DB:ID NAME ID NODE ROLE SSL </span></span><span class="line"><span class="cl">db:6 tr02 endpoint:6:1 node:1 all-master-shards No </span></span></code></pre> </div> <h2 id="migrate-shard"> <code> migrate shard </code> </h2> <p> Moves one or more shards to a new node in the same cluster. </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin migrate shard &lt;id1.. idN&gt; </span></span><span class="line"><span class="cl"> <span class="o">[</span> preserve_roles <span class="o">]</span> </span></span><span class="line"><span class="cl"> target_node &lt;id&gt; </span></span><span class="line"><span class="cl"> <span class="o">[</span> override_policy <span class="o">]</span> </span></span></code></pre> </div> <h3 id="parameters-4"> Parameters </h3> <table> <thead> <tr> <th> Parameter </th> <th> Type/Value </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> shard </td> <td> list of shard IDs </td> <td> Shards to migrate </td> </tr> <tr> <td> preserve_roles </td> <td> </td> <td> Performs an additional failover to guarantee the primary shards' roles are preserved </td> </tr> <tr> <td> target_node </td> <td> integer </td> <td> Migration target node </td> </tr> <tr> <td> override_policy </td> <td> </td> <td> Overrides the rack aware policy and allows primary and replica shards on the same node </td> </tr> </tbody> </table> <h3 id="returns-4"> Returns </h3> <p> Returns <code> Done </code> if the migration completed successfully. Otherwise, returns an error. </p> <p> Use <a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/status/#status-shards"> <code> rladmin status shards </code> </a> to verify the migration completed. </p> <h3 id="example-4"> Example </h3> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ rladmin status shards db db:5 </span></span><span class="line"><span class="cl">SHARDS: </span></span><span class="line"><span class="cl">DB:ID NAME ID NODE ROLE SLOTS USED_MEMORY STATUS </span></span><span class="line"><span class="cl">db:5 tr01 redis:12 node:2 master 0-16383 3.01MB OK </span></span><span class="line"><span class="cl">db:5 tr01 redis:13 node:3 slave 0-16383 3.1MB OK </span></span><span class="line"><span class="cl">$ rladmin migrate shard <span class="m">13</span> target_node <span class="m">1</span> </span></span><span class="line"><span class="cl">Monitoring d2637eea-9504-4e94-a70c-76df087efcb2 </span></span><span class="line"><span class="cl">queued - migrate_shards </span></span><span class="line"><span class="cl">.running - migrate_shards </span></span><span class="line"><span class="cl">Executing migrate_redis with shards_uids <span class="o">[</span><span class="s1">'13'</span><span class="o">]</span> </span></span><span class="line"><span class="cl">Ocompleted - migrate_shards </span></span><span class="line"><span class="cl">Done </span></span><span class="line"><span class="cl">$ rladmin status shards db db:5 </span></span><span class="line"><span class="cl">SHARDS: </span></span><span class="line"><span class="cl">DB:ID NAME ID NODE ROLE SLOTS USED_MEMORY STATUS </span></span><span class="line"><span class="cl">db:5 tr01 redis:12 node:2 master 0-16383 3.01MB OK </span></span><span class="line"><span class="cl">db:5 tr01 redis:13 node:1 slave 0-16383 3.04MB OK </span></span></code></pre> </div> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/references/cli-utilities/rladmin/migrate/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/release-notes/.html
<section class="prose w-full py-12 max-w-none"> <h1> Release notes </h1> <p> Here's what changed recently in Redis Enterprise Software: </p> <table> <thead> <tr> <th style="text-align:left"> Version (Release date) </th> <th style="text-align:left"> Major changes </th> <th style="text-align:left"> Redis CE compatibility </th> </tr> </thead> <tbody> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/release-notes/rs-7-8-releases/"> 7.8.2 releases </a> </td> <td style="text-align:left"> Redis Community Edition 7.4 features. Hash field expiration. Client-side caching support. Metrics stream engine preview. New APIs to check database availability, rebalance shards, fail over shards, and control database traffic. Cluster Manager UI enhancements for node actions, database tags, and database configuration. User manager role. Log rotation based on both size and time. Module management enhancements. Configurable minimum password length. Configurable license expiration alert threshold. </td> <td style="text-align:left"> Redis 7.4.0 </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/release-notes/rs-7-4-2-releases/"> 7.4.x releases </a> </td> <td style="text-align:left"> New Cluster Manager UI enhancements, including Active-Active database management. Full TLS 1.3 support. Automatic recovery configuration. Full IPv6 support, including for internal traffic. Maintenance mode enhancements. Module management enhancements. RHEL 9 support. </td> <td style="text-align:left"> Redis 7.2.0 </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/release-notes/rs-7-2-4-releases/"> 7.2.4 releases </a> </td> <td style="text-align:left"> Redis 7.0 and 7.2 features. Auto Tiering (enhanced successor to Redis on Flash). RESP3 support. Sharded pub/sub. Preview of the new Cluster Manager UI. Redis Stack 7.2 features. Three Redis database versions. License file structure updates. Redis ACL selectors and enhanced key-based permissions. New INFO fields. Log rotation enhancements. Multi-OS upgrade support for clusters with modules. </td> <td style="text-align:left"> Redis 7.2.0 </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/release-notes/rs-6-4-2-releases/"> 6.4.2 releases </a> </td> <td style="text-align:left"> Pub/sub ACLs &amp; default permissions. Validate client certificates by subject attributes. Ubuntu 20.04 support. </td> <td style="text-align:left"> Redis 6.2.10 </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/release-notes/rs-6-2-18-releases/"> 6.2.18 releases </a> </td> <td style="text-align:left"> Database auditing. Private key encryption. Active-Active database support for MEMORY USAGE command. </td> <td style="text-align:left"> Redis 6.2.6 </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/release-notes/rs-6-2-12/"> 6.2.12 (August 2022) </a> </td> <td style="text-align:left"> OCSP Support. Password &amp; session configuration changes. RHEL 8.6 support. </td> <td style="text-align:left"> Redis 6.2.6 </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/release-notes/rs-6-2-10-february-2022/"> 6.2.10 (February 2022) </a> </td> <td style="text-align:left"> Python 3 support. RHEL 8.5 support. </td> <td style="text-align:left"> Redis 6.2.5 </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/release-notes/rs-6-2-8-october-2021/"> 6.2.8 (October 2021) </a> </td> <td style="text-align:left"> RHEL 8 support. Set backup start time. </td> <td style="text-align:left"> Redis 6.2.3 </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/release-notes/rs-6-2-4-august-2021/"> 6.2.4 (August 2021) </a> </td> <td style="text-align:left"> Internode encryption. Nginx replaced by envoy. New upgrade policies/behavior. </td> <td style="text-align:left"> Redis 6.2 </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/release-notes/rs-6-0-20-april-2021/"> 6.0.20 (April 2021) </a> </td> <td style="text-align:left"> Role-based LDAP integration. Enhanced client mutual authentication. Active-Active improvements for eviction policies, migration, and the BITFIELD data type. </td> <td style="text-align:left"> Redis 6.0.9 </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/release-notes/rs-6-0-12-january-2021/"> 6.0.12 (January 2021) </a> </td> <td style="text-align:left"> Distribute synchronization across nodes for Active-Active and Active-Passive databases. Disable internal services to free memory. User accounts support password rotation. Module depdencies automatically installed. Syncer process recovery. </td> <td style="text-align:left"> Redis 6.0.6 </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/release-notes/rs-6-0-8-september-2020/"> 6.0.8 (September 2020) </a> </td> <td style="text-align:left"> RediSearch 2.0 support. Improved rladmin support for module upgrades. </td> <td style="text-align:left"> Redis 6.0.5 </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/release-notes/rs-6-0-may-2020/"> 6.0 (May 2020) </a> </td> <td style="text-align:left"> ACL and RBAC improvements for database access. Active-Active databases support Redis Streams. </td> <td style="text-align:left"> Redis 6 </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/release-notes/legacy-release-notes/"> Previous releases </a> </td> <td style="text-align:left"> Release notes for Redis Enterprise Software 5.6.0 (April 2020) and earlier versions. </td> <td style="text-align:left"> </td> </tr> </tbody> </table> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/release-notes/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/integrate/redis-data-integration/reference/.html
<section class="prose w-full py-12 max-w-none"> <h1> Reference </h1> <p class="text-lg -mt-5 mb-10"> View reference material for Redis Data Integration </p> <nav> <a href="/docs/latest/integrate/redis-data-integration/reference/config-yaml-reference/"> Redis Data Integration configuration file </a> <p> Redis Data Integration configuration file reference </p> <a href="/docs/latest/integrate/redis-data-integration/reference/jmespath-custom-functions/"> JMESPath custom functions </a> <p> JMESPath custom function reference </p> <a href="/docs/latest/integrate/redis-data-integration/reference/ports/"> RDI ports and protocols </a> <p> Network ports and protocols used by RDI </p> <a href="/docs/latest/integrate/redis-data-integration/reference/cli/"> CLI reference </a> <p> Reference for the RDI CLI commands </p> <a href="/docs/latest/integrate/redis-data-integration/reference/data-transformation/"> Data transformation reference </a> <p> View reference material for RDI data transformations </p> </nav> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/integrate/redis-data-integration/reference/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/integrate/redis-data-integration/reference/data-transformation/rename_field/.html
<section class="prose w-full py-12 max-w-none"> <h1> rename_field </h1> <p class="text-lg -mt-5 mb-10"> Rename fields. All other fields remain unchanged. </p> <p> Rename fields. All other fields remain unchanged. </p> <p> <strong> Option 1 (alternative): </strong> Rename multiple fields </p> <p> <strong> Properties </strong> </p> <table> <thead> <tr> <th> Name </th> <th> Type </th> <th> Description </th> <th> Required </th> </tr> </thead> <tbody> <tr> <td> <a href="#option1fields"> <strong> fields </strong> </a> </td> <td> <code> object[] </code> </td> <td> Fields <br/> </td> <td> yes </td> </tr> </tbody> </table> <p> <strong> Additional Properties: </strong> not allowed <br/> <strong> Example </strong> </p> <div class="highlight"> <pre class="chroma"><code class="language-yaml" data-lang="yaml"><span class="line"><span class="cl"><span class="nt">source</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">server_name</span><span class="p">:</span><span class="w"> </span><span class="l">redislabs</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">schema</span><span class="p">:</span><span class="w"> </span><span class="l">dbo</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">table</span><span class="p">:</span><span class="w"> </span><span class="l">emp</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">transform</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">uses</span><span class="p">:</span><span class="w"> </span><span class="l">rename_field</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">with</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">fields</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">from_field</span><span class="p">:</span><span class="w"> </span><span class="l">name.lname</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">to_field</span><span class="p">:</span><span class="w"> </span><span class="l">name.last_name</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">from_field</span><span class="p">:</span><span class="w"> </span><span class="l">name.fname</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">to_field</span><span class="p">:</span><span class="w"> </span><span class="l">name.first_name</span><span class="w"> </span></span></span></code></pre> </div> <p> <strong> Option 2 (alternative): </strong> Rename one field </p> <p> <strong> Properties </strong> </p> <table> <thead> <tr> <th> Name </th> <th> Type </th> <th> Description </th> <th> Required </th> </tr> </thead> <tbody> <tr> <td> <strong> from_field </strong> </td> <td> <code> string </code> </td> <td> From field <br/> </td> <td> yes </td> </tr> <tr> <td> <strong> to_field </strong> </td> <td> <code> string </code> </td> <td> To field <br/> </td> <td> yes </td> </tr> </tbody> </table> <p> <strong> Additional Properties: </strong> not allowed </p> <p> <strong> Example </strong> </p> <div class="highlight"> <pre class="chroma"><code class="language-yaml" data-lang="yaml"><span class="line"><span class="cl"><span class="nt">source</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">server_name</span><span class="p">:</span><span class="w"> </span><span class="l">redislabs</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">schema</span><span class="p">:</span><span class="w"> </span><span class="l">dbo</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">table</span><span class="p">:</span><span class="w"> </span><span class="l">emp</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">transform</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">uses</span><span class="p">:</span><span class="w"> </span><span class="l">rename_field</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">with</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">from_field</span><span class="p">:</span><span class="w"> </span><span class="l">name.lname</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">to_field</span><span class="p">:</span><span class="w"> </span><span class="l">name.last_name</span><span class="w"> </span></span></span></code></pre> </div> <p> <a name="option1fields"> </a> </p> <h2 id="option-1-fields-array"> Option 1: fields[]: array </h2> <p> Fields </p> <p> <strong> Items </strong> </p> <p> <strong> Item Properties </strong> </p> <table> <thead> <tr> <th> Name </th> <th> Type </th> <th> Description </th> <th> Required </th> </tr> </thead> <tbody> <tr> <td> <strong> from_field </strong> </td> <td> <code> string </code> </td> <td> From field <br/> </td> <td> yes </td> </tr> <tr> <td> <strong> to_field </strong> </td> <td> <code> string </code> </td> <td> To field <br/> </td> <td> yes </td> </tr> </tbody> </table> <p> <strong> Item Additional Properties: </strong> not allowed </p> <p> <strong> Example </strong> </p> <div class="highlight"> <pre class="chroma"><code class="language-yaml" data-lang="yaml"><span class="line"><span class="cl">- {}<span class="w"> </span></span></span></code></pre> </div> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/integrate/redis-data-integration/reference/data-transformation/rename_field/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rc/databases/configuration/data-eviction-policies/.html
<section class="prose w-full py-12 max-w-none"> <h1> Data eviction </h1> <p class="text-lg -mt-5 mb-10"> Data eviction policies control what happens when new data exceeds the memory limits of a database. Here, you'll learn the available policies and how to change which one is used for a database. </p> <p> The data eviction policy of a database controls what happens when new data exceeds the memory size of a database. Typically, such situations require <em> evicting </em> (or deleting) data previously added to the database. </p> <p> You can <a href="/docs/latest/operate/rc/databases/view-edit-database/"> edit database details </a> to change the <strong> Data eviction policy </strong> setting at the database level. </p> <h2 id="available-policies"> Available policies </h2> <p> For each database, you can choose from these data eviction policies: </p> <table> <thead> <tr> <th style="text-align:left"> <strong> Available policies </strong> </th> <th style="text-align:left"> <strong> Description </strong> </th> </tr> </thead> <tbody> <tr> <td style="text-align:left"> allkeys-lru </td> <td style="text-align:left"> Keeps most recently used keys; removes least recently used (LRU) keys </td> </tr> <tr> <td style="text-align:left"> allkeys-lfu </td> <td style="text-align:left"> Keeps frequently used keys; removes least frequently used (LFU) keys </td> </tr> <tr> <td style="text-align:left"> allkeys-random </td> <td style="text-align:left"> Randomly removes keys </td> </tr> <tr> <td style="text-align:left"> volatile-lru </td> <td style="text-align:left"> Removes least recently used keys with <code> expire </code> field set to true ( <em> Default </em> ) </td> </tr> <tr> <td style="text-align:left"> volatile-lfu </td> <td style="text-align:left"> Removes least frequently used keys with <code> expire </code> field set to true </td> </tr> <tr> <td style="text-align:left"> volatile-random </td> <td style="text-align:left"> Randomly removes keys with <code> expire </code> field set to true </td> </tr> <tr> <td style="text-align:left"> volatile-ttl </td> <td style="text-align:left"> Removes keys with expire field set to true and the shortest remaining time-to-live (TTL) value </td> </tr> <tr> <td style="text-align:left"> no eviction </td> <td style="text-align:left"> New values aren't saved when memory limit is reached <br/> <br/> When a database uses replication, this applies to the primary database </td> </tr> </tbody> </table> <h2 id="prevent-data-eviction"> Prevent data eviction </h2> <p> Redis Cloud supports <a href="/docs/latest/operate/rs/databases/auto-tiering/"> Auto Tiering </a> to prevent data eviction but maintain high performance. </p> <p> Auto Tiering can extend your database across RAM and Flash Memory and intelligently manage "hot" (active) data in RAM and "cold" (less active) data in Flash memory (SSD). </p> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rc/databases/configuration/data-eviction-policies/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/kubernetes/active-active/create-aa-crdb-cli/.html
<section class="prose w-full py-12 max-w-none"> <h1> Create Active-Active databases with crdb-cli </h1> <p class="text-lg -mt-5 mb-10"> This section shows how to set up an Active-Active Redis Enterprise database on Kubernetes using the Redis Enterprise Software operator. </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> Versions 6.4.2 and later support the Active-Active database controller. This controller allows you to create Redis Enterprise Active-Active databases (REAADB) and Redis Enterprise remote clusters (RERC) with custom resources. We recommend using the <a href="/docs/latest/operate/kubernetes/active-active/create-reaadb/"> REAADB method for creating Active-Active databases </a> . </div> </div> <p> On Kubernetes, Redis Enterprise <a href="/docs/latest/operate/rs/databases/active-active/"> Active-Active </a> databases provide read-and-write access to the same dataset from different Kubernetes clusters. For more general information about Active-Active, see the <a href="/docs/latest/operate/rs/databases/active-active/"> Redis Enterprise Software docs </a> . </p> <p> Creating an Active-Active database requires routing <a href="/docs/latest/operate/kubernetes/networking/"> network access </a> between two Redis Enterprise clusters residing in different Kubernetes clusters. Without the proper access configured for each cluster, syncing between the databases instances will fail. </p> <p> This process consists of: </p> <ol> <li> Documenting values to be used in later steps. It's important these values are correct and consistent. </li> <li> Editing the Redis Enterprise cluster (REC) spec file to include the <code> ActiveActive </code> section. This will be slightly different depending on the K8s distribution you are using. </li> <li> Creating the database with the <code> crdb-cli </code> command. These values must match up with values in the REC resource spec. </li> </ol> <h2 id="prerequisites"> Prerequisites </h2> <p> Before creating Active-Active databases, you'll need admin access to two or more working Kubernetes clusters that each have: </p> <ul> <li> Routing for external access with an <a href="/docs/latest/operate/kubernetes/networking/ingress/"> ingress resources </a> (or <a href="/docs/latest/operate/kubernetes/networking/routes/"> route resources </a> on OpenShift). </li> <li> A working <a href="/docs/latest/operate/kubernetes/reference/redis_enterprise_cluster_api/"> Redis Enterprise cluster (REC) </a> with a unique name. </li> <li> Enough memory resources available for the database (see <a href="/docs/latest/operate/rs/installing-upgrading/install/plan-deployment/hardware-requirements/"> hardware requirements </a> ). </li> </ul> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> The <code> activeActive </code> field and the <code> ingressOrRouteSpec </code> field cannot coexist in the same REC. If you configured your ingress via the <code> ingressOrRouteSpec </code> field in the REC, create your Active-Active database with the RedisEnterpriseActiveActiveDatabase (REAADB) custom resource. </div> </div> <h2 id="document-required-parameters"> Document required parameters </h2> <p> The most common mistake when setting up Active-Active databases is incorrect or inconsistent parameter values. The values listed in the resource file must match those used in the crdb-cli command. </p> <ul> <li> <strong> Database name </strong> <code> &lt;db-name&gt; </code> : <ul> <li> Description: Combined with ingress suffix to create the Active-Active database hostname </li> <li> Format: string </li> <li> Example value: <code> myaadb </code> </li> <li> How you get it: you choose </li> <li> The database name requirements are: <ul> <li> Maximum of 63 characters </li> <li> Only letter, number, or hyphen (-) characters </li> <li> Starts with a letter; ends with a letter or digit. </li> <li> Database name is not case-sensitive </li> </ul> </li> </ul> </li> </ul> <p> You'll need the following information for each participating Redis Enterprise cluster (REC): </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> You'll need to create DNS aliases to resolve your API hostname <code> &lt;api-hostname&gt; </code> , <code> &lt;ingress-suffix&gt; </code> , <code> &lt;replication-hostname&gt; </code> to the IP address for the ingress controller’s LoadBalancer (or routes in Openshift) for each database. To avoid entering multiple DNS records, you can use a wildcard in your alias (such as *.ijk.example.com). </div> </div> <ul> <li> <strong> REC hostname </strong> <code> &lt;rec-hostname&gt; </code> : <ul> <li> Description: Hostname used to identify your Redis Enterprise cluster in the <code> crdb-cli </code> command. This MUST be different from other participating clusters. </li> <li> Format: <code> &lt;rec-name&gt;.&lt;namespace&gt;.svc.cluster.local </code> </li> <li> Example value: <code> rec01.ns01.svc.cluster.local </code> </li> <li> How to get it: List all your Redis Enterprise clusters <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">kubectl get rec </span></span></code></pre> </div> </li> </ul> </li> <li> <strong> API hostname </strong> <code> &lt;api-hostname&gt; </code> : <ul> <li> Description: Hostname used to access the Redis Enterprise cluster API from outside the K8s cluster </li> <li> Format: string </li> <li> Example value: <code> api.ijk.example.com </code> </li> </ul> </li> <li> <strong> Ingress suffix </strong> <code> &lt;ingress-suffix&gt; </code> : <ul> <li> Description: Combined with database name to create the Active-Active database hostname </li> <li> Format: string </li> <li> Example value: <code> -cluster.ijk.example.com </code> </li> </ul> </li> <li> <a href="/docs/latest/operate/kubernetes/security/manage-rec-credentials/"> <strong> REC admin credentials </strong> </a> <code> &lt;username&gt; &lt;password&gt; </code> : <ul> <li> Description: Admin username and password for the REC stored in a secret </li> <li> Format: string </li> <li> Example value: username: <code> [email protected] </code> , password: <code> something </code> </li> <li> How to get them: <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">kubectl get secret &lt;rec-name&gt; <span class="se">\ </span></span></span><span class="line"><span class="cl"><span class="se"></span> -o <span class="nv">jsonpath</span><span class="o">=</span><span class="s1">'{.data.username}'</span> <span class="p">|</span> base64 --decode </span></span><span class="line"><span class="cl">kubectl get secret &lt;rec-name&gt; <span class="se">\ </span></span></span><span class="line"><span class="cl"><span class="se"></span> -o <span class="nv">jsonpath</span><span class="o">=</span><span class="s1">'{.data.password}'</span> <span class="p">|</span> base64 --decode </span></span></code></pre> </div> </li> </ul> </li> <li> <strong> Replication hostname </strong> <code> &lt;replication-hostname&gt; </code> : <ul> <li> Description: Hostname used inside the ingress for the database </li> <li> Format: <code> &lt;db-name&gt;&lt;ingress-suffix&gt; </code> </li> <li> Example value: <code> myaadb-cluster.ijk.example.com </code> </li> <li> How to get it: Combine <code> &lt;db-name&gt; </code> and <code> &lt;ingress-suffix </code> &gt; values you documented above. </li> </ul> </li> <li> <strong> Replication endpoint </strong> <code> &lt;replication-endpoint&gt; </code> : <ul> <li> Description: Endpoint used externally to contact the database </li> <li> Format: <code> &lt;db-name&gt;&lt;ingress-suffix&gt;:443 </code> </li> <li> Example value: <code> myaadb-cluster.ijk.example.com:443 </code> </li> <li> How to get it: <code> &lt;replication-hostname&gt;:443 </code> </li> </ul> </li> </ul> <h2 id="add-activeactive-section-to-the-rec-resource-file"> Add <code> activeActive </code> section to the REC resource file </h2> <p> From inside your K8s cluster, edit your Redis Enterprise cluster (REC) resource to add the following to the <code> spec </code> section. Do this for each participating cluster. </p> <p> The operator uses the API hostname ( <code> &lt;api-hostname&gt; </code> ) to create an ingress to the Redis Enterprise cluster's API; this only happens once per cluster. Every time a new Active-Active database instance is created on this cluster, the operator creates a new ingress route to the database with the ingress suffix ( <code> &lt;ingress-suffix&gt; </code> ). The hostname for each new database will be in the format <nobr> <code> &lt;db-name&gt;&lt;ingress-suffix&gt; </code> </nobr> . </p> <h3 id="using-ingress-controller"> Using ingress controller </h3> <ol> <li> If your cluster uses an <a href="/docs/latest/operate/kubernetes/networking/ingress/"> ingress controller </a> , add the following to the <code> spec </code> section of your REC resource file. </li> </ol> <p> Nginx: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">activeActive: </span></span><span class="line"><span class="cl"> apiIngressUrl: &lt;api-hostname&gt; </span></span><span class="line"><span class="cl"> dbIngressSuffix: &lt;ingress-suffix&gt; </span></span><span class="line"><span class="cl"> ingressAnnotations: </span></span><span class="line"><span class="cl"> kubernetes.io/ingress.class: nginx </span></span><span class="line"><span class="cl"> nginx.ingress.kubernetes.io/backend-protocol: HTTPS </span></span><span class="line"><span class="cl"> nginx.ingress.kubernetes.io/ssl-passthrough: <span class="s2">"true"</span> </span></span><span class="line"><span class="cl"> method: ingress </span></span></code></pre> </div> <p> HAproxy: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">activeActive: </span></span><span class="line"><span class="cl"> apiIngressUrl: &lt;api-hostname&gt; </span></span><span class="line"><span class="cl"> dbIngressSuffix: &lt;ingress-suffix&gt; </span></span><span class="line"><span class="cl"> ingressAnnotations: </span></span><span class="line"><span class="cl"> kubernetes.io/ingress.class: haproxy </span></span><span class="line"><span class="cl"> ingress.kubernetes.io/ssl-passthrough: <span class="s2">"true"</span> </span></span><span class="line"><span class="cl"> method: ingress </span></span></code></pre> </div> <ol start="2"> <li> <p> After the changes are saved and applied, you can verify a new ingress was created for the API. </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ kubectl get ingress </span></span><span class="line"><span class="cl">NAME HOSTS ADDRESS PORTS AGE </span></span><span class="line"><span class="cl">rec01 api.abc.cde.example.com 225161f845b278-111450635.us.cloud.com <span class="m">80</span> 24h </span></span></code></pre> </div> </li> <li> <p> Verify you can access the API from outside the K8s cluster. </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">curl -k -L -i -u &lt;username&gt;:&lt;password&gt; https://&lt;api-hostname&gt;/v1/cluster </span></span></code></pre> </div> <p> If the API call fails, create a DNS alias that resolves your API hostname ( <code> &lt;api-hostname&gt; </code> ) to the IP address for the ingress controller's LoadBalancer. </p> </li> <li> <p> Make sure you have DNS aliases for each database that resolve your API hostname <code> &lt;api-hostname&gt; </code> , <code> &lt;ingress-suffix&gt; </code> , <code> &lt;replication-hostname&gt; </code> to the IP address of the ingress controller’s LoadBalancer. To avoid entering multiple DNS records, you can use a wildcard in your alias (such as <code> *.ijk.example.com </code> ). </p> </li> </ol> <h4 id="if-using-istio-gateway-and-virtualservice"> If using Istio Gateway and VirtualService </h4> <p> No changes are required to the REC spec if you are using <a href="/docs/latest/operate/kubernetes/networking/istio-ingress/"> Istio </a> in place of an ingress controller. The <code> activeActive </code> section added above creates ingress resources. The two custom resources used to configure Istio (Gateway and VirtualService) replace the need for ingress resources. </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Warning: </div> These custom resources are not controlled by the operator and will need to be configured and maintained manually. </div> </div> <p> For each cluster, verify the VirtualService resource has two <code> - match: </code> blocks in the <code> tls </code> section. The hostname under <code> sniHosts: </code> should match your <code> &lt;replication-hostname&gt; </code> . </p> <h3 id="using-openshift-routes"> Using OpenShift routes </h3> <ol> <li> <p> Make sure your Redis Enterprise cluster (REC) has a different name ( <code> &lt;rec-name.namespace&gt; </code> ) than any other participating clusters. If not, you'll need to manually rename the REC or move it to a different namespace. You can check your new REC name with: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">oc get rec -o <span class="nv">jsonpath</span><span class="o">=</span><span class="s1">'{.items[0].metadata.name}'</span> </span></span></code></pre> </div> <p> If the rec name was modified, reapply <a href="https://github.com/RedisLabs/redis-enterprise-k8s-docs/blob/master/openshift/scc.yaml"> scc.yaml </a> to the namespace to reestablish security privileges. </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">oc apply -f scc.yaml </span></span><span class="line"><span class="cl">oc adm policy add-scc-to-group redis-enterprise-scc-v2 system:serviceaccounts:&lt;namespace&gt; </span></span></code></pre> </div> <p> Releases before 6.4.2-6 use the earlier version of the SCC, named <code> redis-enterprise-scc </code> . </p> </li> <li> <p> Make sure you have DNS aliases for each database that resolve your API hostname <code> &lt;api-hostname&gt; </code> , <code> &lt;ingress-suffix&gt; </code> , <code> &lt;replication-hostname&gt; </code> to the route IP address. To avoid entering multiple DNS records, you can use a wildcard in your alias (such as <code> *.ijk.example.com </code> ). </p> </li> <li> <p> If your cluster uses <a href="/docs/latest/operate/kubernetes/networking/routes/"> OpenShift routes </a> , add the following to the <code> spec </code> section of your Redis Enterprise cluster (REC) resource file. </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">activeActive: </span></span><span class="line"><span class="cl"> apiIngressUrl: &lt;api-hostname&gt; </span></span><span class="line"><span class="cl"> dbIngressSuffix: &lt;ingress-suffix&gt; </span></span><span class="line"><span class="cl"> method: openShiftRoute </span></span></code></pre> </div> </li> <li> <p> Make sure you have DNS aliases that resolve to the routes IP for both the API hostname ( <code> &lt;api-hostname&gt; </code> ) and the replication hostname ( <code> &lt;replication-hostname&gt; </code> ) for each database. To avoid entering each database individually, you can use a wildcard in your alias (such as <code> *.ijk.example.com </code> ). </p> </li> <li> <p> After the changes are saved and applied, you can see that a new route was created for the API. </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ oc get route </span></span><span class="line"><span class="cl">NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD </span></span><span class="line"><span class="cl">rec01 api-openshift.apps.abc.example.com rec01 api passthrough None </span></span></code></pre> </div> </li> </ol> <h2 id="create-an-active-active-database-with-crdb-cli"> Create an Active-Active database with <code> crdb-cli </code> </h2> <p> The <code> crdb-cli </code> command can be run from any Redis Enterprise pod hosted on any participating K8s cluster. You'll need the values for the <a href="/docs/latest/operate/kubernetes/active-active/create-aa-crdb-cli/#document-required-parameters"> required parameters </a> for each Redis Enterprise cluster. </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">crdb-cli crdb create <span class="se">\ </span></span></span><span class="line"><span class="cl"><span class="se"></span> --name &lt;db-name&gt; <span class="se">\ </span></span></span><span class="line"><span class="cl"><span class="se"></span> --memory-size &lt;mem-size&gt; <span class="se">\ </span></span></span><span class="line"><span class="cl"><span class="se"></span> --encryption yes <span class="se">\ </span></span></span><span class="line"><span class="cl"><span class="se"></span> --instance <span class="nv">fqdn</span><span class="o">=</span>&lt;rec-hostname-01&gt;,url<span class="o">=</span>https://&lt;api-hostname-01&gt;,username<span class="o">=</span>&lt;username-01&gt;,password<span class="o">=</span>&lt;password-01&gt;,replication_endpoint<span class="o">=</span>&lt;replication-endpoint-01&gt;,replication_tls_sni<span class="o">=</span>&lt;replication-hostname-01&gt; <span class="se">\ </span></span></span><span class="line"><span class="cl"><span class="se"></span> --instance <span class="nv">fqdn</span><span class="o">=</span>&lt;rec-hostname-02&gt;,url<span class="o">=</span>https://&lt;api-hostname-02&gt;,username<span class="o">=</span>&lt;username-02&gt;,password<span class="o">=</span>&lt;password-02&gt;,replication_endpoint<span class="o">=</span>&lt;replication-endpoint-02&gt;,replication_tls_sni<span class="o">=</span>&lt;replication-hostname-02&gt; </span></span></code></pre> </div> <p> To create a database that syncs between more than two instances, add additional <code> --instance </code> arguments. </p> <p> See the <a href="/docs/latest/operate/rs/references/cli-utilities/crdb-cli/"> <code> crdb-cli </code> reference </a> for more options. </p> <h2 id="test-your-database"> Test your database </h2> <p> The easiest way to test your Active-Active database is to set a key-value pair in one database and retrieve it from the other. </p> <p> You can connect to your databases with the instructions in <a href="/docs/latest/operate/kubernetes/re-databases/db-controller/#connect-to-a-database"> Manage databases </a> . Set a test key with <code> SET foo bar </code> in the first database. If your Active-Active deployment is working properly, when connected to your second database, <code> GET foo </code> should output <code> bar </code> . </p> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/kubernetes/active-active/create-aa-crdb-cli/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/renamenx/.html
<section class="prose w-full py-12"> <h1 class="command-name"> RENAMENX </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">RENAMENX key newkey</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available since: </dt> <dd class="m-0"> 1.0.0 </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(1) </dd> <dt class="font-semibold text-redis-ink-900 m-0"> ACL categories: </dt> <dd class="m-0"> <code> @keyspace </code> <span class="mr-1 last:hidden"> , </span> <code> @write </code> <span class="mr-1 last:hidden"> , </span> <code> @fast </code> <span class="mr-1 last:hidden"> , </span> </dd> </dl> <p> Renames <code> key </code> to <code> newkey </code> if <code> newkey </code> does not yet exist. It returns an error when <code> key </code> does not exist. </p> <p> In Cluster mode, both <code> key </code> and <code> newkey </code> must be in the same <strong> hash slot </strong> , meaning that in practice only keys that have the same hash tag can be reliably renamed in cluster. </p> <h2 id="examples"> Examples </h2> <div class="bg-slate-900 border-b border-slate-700 rounded-t-xl px-4 py-3 w-full flex"> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M2.5 10C2.5 5.85786 5.85786 2.5 10 2.5C14.1421 2.5 17.5 5.85786 17.5 10C17.5 14.1421 14.1421 17.5 10 17.5C5.85786 17.5 2.5 14.1421 2.5 10Z"> </path> </svg> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M10 2.5L18.6603 17.5L1.33975 17.5L10 2.5Z"> </path> </svg> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M10 2.5L12.0776 7.9322L17.886 8.22949L13.3617 11.8841L14.8738 17.5L10 14.3264L5.1262 17.5L6.63834 11.8841L2.11403 8.22949L7.92238 7.9322L10 2.5Z"> </path> </svg> </div> <form class="redis-cli overflow-y-auto max-h-80"> <pre tabindex="0">redis&gt; SET mykey "Hello" "OK" redis&gt; SET myotherkey "World" "OK" redis&gt; RENAMENX mykey myotherkey (integer) 0 redis&gt; GET myotherkey "World" </pre> <div class="prompt" style=""> <span> redis&gt; </span> <input autocomplete="off" name="prompt" spellcheck="false" type="text"/> </div> </form> <h2 id="resp2resp3-reply"> RESP2/RESP3 Reply </h2> <p> One of the following: </p> <ul> <li> <a href="../../develop/reference/protocol-spec#integers"> Integer reply </a> : <code> 1 </code> if <em> key </em> was renamed to <em> newkey </em> . </li> <li> <a href="../../develop/reference/protocol-spec#integers"> Integer reply </a> : <code> 0 </code> if <em> newkey </em> already exists. </li> </ul> <br/> <h2> History </h2> <ul> <li> Starting with Redis version 3.2.0: The command no longer returns an error when source and destination names are the same. </li> </ul> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/renamenx/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/develop/connect/insight/.html
<section class="prose w-full py-12 max-w-none"> <h1> Redis Insight </h1> <p class="text-lg -mt-5 mb-10"> Visualize and optimize Redis data, connect to RDI, and more. </p> <p> <a href="https://discord.gg/QUkjSsk"> <img alt="Discord" src="https://img.shields.io/discord/697882427875393627?style=flat-square"/> </a> <a href="https://github.com/redisinsight/redisinsight/"> <img alt="Github" src="https://img.shields.io/static/v1?label=&amp;message=repository&amp;color=5961FF&amp;logo=github"/> </a> </p> <p> Redis Insight is a powerful tool for visualizing and optimizing data in Redis or Redis Stack, making real-time application development easier and more fun than ever before. Redis Insight lets you do both GUI- and CLI-based interactions in a fully-featured desktop GUI client. </p> <h3 id="installation-and-release-notes"> Installation and release notes </h3> <ul> <li> <p> See <a href="/docs/latest/operate/redisinsight/install/"> these pages </a> for installation information. </p> </li> <li> <p> <a href="https://github.com/Redis-Insight/Redis-Insight/releases"> Redis Insight Release Notes </a> </p> </li> </ul> <h2 id="overview"> Overview </h2> <h3 id="connection-management"> Connection management </h3> <ul> <li> Automatically discover and add your local Redis or Redis Stack databases (that use standalone connection type and do not require authentication). </li> <li> Discover your databases in Redis Enterprise Cluster and databases with Flexible plans in Redis Cloud. </li> <li> Use a form to enter your connection details and add any Redis database running anywhere (including Redis Community Edition Cluster or Sentinel). </li> <li> Connect to a Redis Data Integration (RDI) management plane, create, test, and deploy RDI pipelines, and view RDI statistics. </li> </ul> <img src="images/Databases.png"/> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> When you add a Redis database for a particular user using the <code> username </code> and <code> password </code> fields, that user must be able to run the <code> INFO </code> command. See the <a href="/docs/latest/operate/oss_and_stack/management/security/acl/"> access control list (ACL) documentation </a> for more information. </div> </div> <h3 id="redis-copilot"> Redis Copilot </h3> <p> Redis Copilot is an AI-powered developer assistant that helps you learn about Redis, explore your Redis data, and build search queries in a conversational manner. It is available in Redis Insight as well as within the Redis public documentation. </p> <p> Currently, Redis Copilot provides two primary features: a general chatbot and a context-aware data chatbot. </p> <p> <strong> General chatbot </strong> : the knowledge-based chatbot serves as an interactive and dynamic documentation interface to simplify the learning process. You can ask specific questions about Redis commands, concepts, and products, and get responses on the fly. The general chatbot is also available in our public docs. </p> <p> <strong> My data chatbot </strong> : the context-aware chatbot available in Redis Insight lets you construct search queries using everyday language rather than requiring specific programming syntax. This feature lets you query and explore data easily and interactively without extensive technical knowledge. </p> <p> Here's an example of using Redis Copilot to search data using a simple, natural language prompt. </p> <img src="images/copilot-example.png"/> <p> See the <a href="/docs/latest/develop/tools/insight/copilot-faq/"> Redis Insight Copilot FAQ </a> for more information. </p> <h3 id="rdi-in-redis-insight"> RDI in Redis Insight </h3> <p> Redis Insight includes Redis Data Integration (RDI) connectivity, which allows you to connect to an RDI management plane, and create, test, and deploy RDI pipelines. Read more about this feature <a href="/docs/latest/develop/tools/insight/rdi-connector/"> here </a> . </p> <h3 id="browser"> Browser </h3> <p> Browse, filter and visualize your key-value Redis data structures. </p> <ul> <li> <p> <a href="https://en.wikipedia.org/wiki/Create,_read,_update_and_delete"> CRUD </a> support for lists, hashes, strings, sets, sorted sets, and streams </p> </li> <li> <p> CRUD support for <a href="/docs/latest/develop/data-types/json/"> JSON </a> </p> </li> <li> <p> Group keys according to their namespaces </p> <img src="images/Browser.png"/> </li> <li> <p> View, validate, and manage your key values in a human-readable format using formatters that prettify and highlight data in different formats (for example, Unicode, JSON, MessagePack, HEX, and ASCII) in the Browser tool. </p> <img src="images/data_formatting.png"/> </li> </ul> <h3 id="profiler"> Profiler </h3> <p> Analyze every command sent to Redis in real time. </p> <img src="images/Profiler.png"/> <h3 id="cli"> CLI </h3> <p> The CLI is accessible at any time within the application. </p> <ul> <li> Employs integrated help to deliver intuitive assistance </li> <li> Use together with a convenient command helper that lets you search and read on Redis commands. </li> </ul> <img src="images/CLI.png"/> <h3 id="workbench"> Workbench </h3> <p> Workbench is an advanced command line interface with intelligent command auto-complete and complex data visualization support. </p> <ul> <li> Built-in guides: you can conveniently discover Redis and Redis Stack features using the built-in guides. </li> <li> Command auto-complete support for all features in Redis and Redis Stack. </li> <li> Advanced, schema-aware auto-complete for Redis Query Engine, which provides for faster query building with context-sensitive suggestions that recognize indexes, schemas, and fields based on your current query. Start typing any Redis Query Engine command in to try this feature. See below for an example of an in-progress <code> FT.SEARCH </code> command. </li> </ul> <img src="images/Workbench_Search.png"/> <p> Workbench also includes: </p> <ul> <li> <p> Visualizations of your indexes, queries, and aggregations. </p> </li> <li> <p> Visualizations of your <a href="/docs/latest/develop/data-types/timeseries/"> time series </a> data. </p> <img src="images/Workbench_TimeSeries.png"/> </li> </ul> <h2 id="tools"> Tools </h2> <h3 id="database-analysis"> Database analysis </h3> <p> Use the database analysis tool to optimize the performance and memory usage of your Redis database. Check data type distribution and memory allocation and review the summary of key expiration time and memory to be freed over time. Inspect the top keys and namespaces sorted by consumed memory or key length and count of keys, respectively. Capture and track the changes in your database by viewing historical analysis reports. Next figure shows a sample database analysis report. </p> <img src="images/database_analysis.png"/> <h3 id="redis-streams-support"> Redis Streams support </h3> <p> Create and manage streams by adding, removing, and filtering entries per timestamp. To see and work with new entries, enable and customize the automatic refresh rate. </p> <p> View and manage the list of consumer groups. See existing consumers in a given consumer name as well as the last messages delivered to them. Inspect the list of pending messages, explicitly acknowledge the processed items, or claim unprocessed messages via Redis Insight. </p> <img src="images/streams.png"/> <h3 id="search-features"> Search features </h3> <p> If you're using Redis Stack's indexing, querying, or full-text search features, Redis Insight provides UI controls to quickly and conveniently run search queries against a preselected index. You can also create a secondary index of your data in a dedicated pane. </p> <img src="images/search.png"/> <h3 id="bulk-actions"> Bulk actions </h3> <p> Easily and quickly delete multiple keys of the same type and/or with the same key name pattern in bulk. To do so, in the List or Tree view, set filters per key type or key names and open the Bulk Actions section. The section displays a summary of all the keys with the expected number of keys that will be deleted based on the set filters. </p> <p> When the bulk deletion is completed, Redis Insight displays the results of this operation with the number of keys processed and the time taken to delete the keys in bulk. Use bulk deletion to optimize the usage of your database based on the results from the Redis database analysis. </p> <img src="images/bulk_actions.png"/> <h3 id="slow-log"> Slow Log </h3> <p> The Slow Log tool displays the list of logs captured by the SLOWLOG command to analyze all commands that exceed a specified runtime, which helps with troubleshooting performance issues. Specify both the runtime and the maximum length of Slowlog (which are server configurations) to configure the list of commands logged and set the auto-refresh interval to automatically update the list of commands displayed. </p> <img src="images/slowlog.png"/> <h2 id="plugins"> Plugins </h2> <p> With Redis Insight you can now also extend the core functionality by building your own data visualizations. See our <a href="https://github.com/Redis-Insight/Redis-Insight/wiki/Plugin-Documentation"> plugin documentation </a> for more information. </p> <h2 id="telemetry"> Telemetry </h2> <p> Redis Insight includes an opt-in telemetry system. This help us improve the developer experience of the app. We value your privacy; all collected data is anonymized. </p> <h2 id="log-files"> Log files </h2> <p> You can review the Redis Insight log files (files with a <code> .log </code> extension) to get detailed information about system issues. These are the locations on supported platforms: </p> <ul> <li> <strong> Docker </strong> : In the <code> /data/logs </code> directory <em> inside the container </em> . </li> <li> <strong> Mac </strong> : In the <code> /Users/&lt;your-username&gt;/.redis-insight </code> directory. </li> <li> <strong> Windows </strong> : In the <code> C:\Users\&lt;your-username&gt;\.redis-insight </code> directory. </li> <li> <strong> Linux </strong> : In the <code> /home/&lt;your-username&gt;/.redis-insight </code> directory. </li> </ul> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> You can install Redis Insight on operating systems that are not officially supported, but it may not behave as expected. </div> </div> <h2 id="redis-insight-api-only-for-docker"> Redis Insight API (only for Docker) </h2> <p> If you are running Redis Insight from <a href="/docs/latest/operate/redisinsight/install/install-on-docker/"> Docker </a> , you can access the API from <code> http://localhost:5540/api/docs </code> . </p> <h2 id="feedback"> Feedback </h2> <p> To provide your feedback, <a href="https://github.com/Redis-Insight/Redis-Insight/issues/new"> open a ticket in our Redis Insight repository </a> . </p> <h2 id="license"> License </h2> <p> Redis Insight is licensed under <a href="https://github.com/Redis-Insight/Redis-Insight/blob/main/LICENSE"> SSPL </a> license. </p> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/develop/tools/insight/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/ts.info.html
<section class="prose w-full py-12"> <h1 class="command-name"> TS.INFO </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">TS.INFO key [DEBUG] </pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available in: </dt> <dd class="m-0"> <a href="/docs/stack"> Redis Stack </a> / <a href="/docs/data-types/timeseries"> TimeSeries 1.0.0 </a> </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(1) </dd> </dl> <p> Return information and statistics for a time series. </p> <p> <a href="#examples"> Examples </a> </p> <h2 id="required-arguments"> Required arguments </h2> <details open=""> <summary> <code> key </code> </summary> is key name of the time series. </details> <h2 id="optional-arguments"> Optional arguments </h2> <details open=""> <summary> <code> [DEBUG] </code> </summary> <p> is an optional flag to get a more detailed information about the chunks. </p> </details> <h2 id="return-value"> Return value </h2> <p> <a href="/docs/latest/develop/reference/protocol-spec/#arrays"> Array reply </a> with information about the time series (name-value pairs): </p> <table> <thead> <tr> <th> Name <br/> <a href="/docs/latest/develop/reference/protocol-spec/#simple-strings"> Simple string reply </a> </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <code> totalSamples </code> </td> <td> <a href="/docs/latest/develop/reference/protocol-spec/#integers"> Integer reply </a> <br/> Total number of samples in this time series </td> </tr> <tr> <td> <code> memoryUsage </code> </td> <td> <a href="/docs/latest/develop/reference/protocol-spec/#integers"> Integer reply </a> <br/> Total number of bytes allocated for this time series, which is the sum of <br/> - The memory used for storing the series' configuration parameters (retention period, duplication policy, etc.) <br/> - The memory used for storing the series' compaction rules <br/> - The memory used for storing the series' labels (key-value pairs) <br/> - The memory used for storing the chunks (chunk header + compressed/uncompressed data) </td> </tr> <tr> <td> <code> firstTimestamp </code> </td> <td> <a href="/docs/latest/develop/reference/protocol-spec/#integers"> Integer reply </a> <br/> First timestamp present in this time series (Unix timestamp in milliseconds) </td> </tr> <tr> <td> <code> lastTimestamp </code> </td> <td> <a href="/docs/latest/develop/reference/protocol-spec/#integers"> Integer reply </a> <br/> Last timestamp present in this time series (Unix timestamp in milliseconds) </td> </tr> <tr> <td> <code> retentionTime </code> </td> <td> <a href="/docs/latest/develop/reference/protocol-spec/#integers"> Integer reply </a> <br/> The retention period, in milliseconds, for this time series </td> </tr> <tr> <td> <code> chunkCount </code> </td> <td> <a href="/docs/latest/develop/reference/protocol-spec/#integers"> Integer reply </a> <br/> Number of chunks used for this time series </td> </tr> <tr> <td> <code> chunkSize </code> </td> <td> <a href="/docs/latest/develop/reference/protocol-spec/#integers"> Integer reply </a> <br/> The initial allocation size, in bytes, for the data part of each new chunk. <br/> Actual chunks may consume more memory. Changing the chunk size (using <a href="/docs/latest/commands/ts.alter/"> <code> TS.ALTER </code> </a> ) does not affect existing chunks. </td> </tr> <tr> <td> <code> chunkType </code> </td> <td> <a href="/docs/latest/develop/reference/protocol-spec/#simple-strings"> Simple string reply </a> <br/> The chunks type: <code> compressed </code> or <code> uncompressed </code> </td> </tr> <tr> <td> <code> duplicatePolicy </code> </td> <td> <a href="/docs/latest/develop/reference/protocol-spec/#simple-strings"> Simple string reply </a> or <a href="/docs/latest/develop/reference/protocol-spec/#bulk-strings"> Nil reply </a> <br/> The <a href="/docs/latest/develop/data-types/timeseries/configuration#duplicate_policy"> duplicate policy </a> of this time series </td> </tr> <tr> <td> <code> labels </code> </td> <td> <a href="/docs/latest/develop/reference/protocol-spec/#arrays"> Array reply </a> or <a href="/docs/latest/develop/reference/protocol-spec/#bulk-strings"> Nil reply </a> <br/> Metadata labels of this time series <br/> Each element is a 2-elements <a href="/docs/latest/develop/reference/protocol-spec/#arrays"> Array reply </a> of ( <a href="/docs/latest/develop/reference/protocol-spec/#bulk-strings"> Bulk string reply </a> , <a href="/docs/latest/develop/reference/protocol-spec/#bulk-strings"> Bulk string reply </a> ) representing (label, value) </td> </tr> <tr> <td> <code> sourceKey </code> </td> <td> <a href="/docs/latest/develop/reference/protocol-spec/#bulk-strings"> Bulk string reply </a> or <a href="/docs/latest/develop/reference/protocol-spec/#bulk-strings"> Nil reply </a> <br/> Key name for source time series in case the current series is a target of a <a href="/docs/latest/commands/ts.createrule"> compaction rule </a> </td> </tr> <tr> <td> <code> rules </code> </td> <td> <a href="/docs/latest/develop/reference/protocol-spec/#arrays"> Array reply </a> <br/> <a href="/docs/latest/commands/ts.createrule"> Compaction rules </a> defined in this time series <br/> Each rule is an <a href="/docs/latest/develop/reference/protocol-spec/#arrays"> Array reply </a> with 4 elements: <br/> - <a href="/docs/latest/develop/reference/protocol-spec/#bulk-strings"> Bulk string reply </a> : The compaction key <br/> - <a href="/docs/latest/develop/reference/protocol-spec/#integers"> Integer reply </a> : The bucket duration <br/> - <a href="/docs/latest/develop/reference/protocol-spec/#simple-strings"> Simple string reply </a> : The aggregator <br/> - <a href="/docs/latest/develop/reference/protocol-spec/#integers"> Integer reply </a> : The alignment (since RedisTimeSeries v1.8) </td> </tr> </tbody> </table> <p> When <a href="/docs/latest/commands/debug/"> <code> DEBUG </code> </a> is specified, the response also contains: </p> <table> <thead> <tr> <th> Name <br/> <a href="/docs/latest/develop/reference/protocol-spec/#simple-strings"> Simple string reply </a> </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <code> keySelfName </code> </td> <td> <a href="/docs/latest/develop/reference/protocol-spec/#bulk-strings"> Bulk string reply </a> <br/> Name of the key </td> </tr> <tr> <td> <code> Chunks </code> </td> <td> <a href="/docs/latest/develop/reference/protocol-spec/#arrays"> Array reply </a> with information about the chunks <br/> Each element is an <a href="/docs/latest/develop/reference/protocol-spec/#arrays"> Array reply </a> of information about a single chunk in a name( <a href="/docs/latest/develop/reference/protocol-spec/#simple-strings"> Simple string reply </a> )-value pairs: <br/> - <code> startTimestamp </code> - <a href="/docs/latest/develop/reference/protocol-spec/#integers"> Integer reply </a> - First timestamp present in the chunk <br/> - <code> endTimestamp </code> - <a href="/docs/latest/develop/reference/protocol-spec/#integers"> Integer reply </a> - Last timestamp present in the chunk <br/> - <code> samples </code> - <a href="/docs/latest/develop/reference/protocol-spec/#integers"> Integer reply </a> - Total number of samples in the chunk <br/> - <code> size </code> - <a href="/docs/latest/develop/reference/protocol-spec/#integers"> Integer reply </a> - the chunk's internal data size (without overheads) in bytes <br/> - <code> bytesPerSample </code> - <a href="/docs/latest/develop/reference/protocol-spec/#bulk-strings"> Bulk string reply </a> (double) - Ratio of <code> size </code> and <code> samples </code> </td> </tr> </tbody> </table> <h2 id="examples"> Examples </h2> <details open=""> <summary> <b> Find information about a temperature/humidity time series by location and sensor type </b> </summary> <p> Create a set of sensors to measure temperature and humidity in your study and kitchen. </p> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">127.0.0.1:6379&gt; TS.CREATE telemetry:study:temperature LABELS room study <span class="nb">type</span> temperature </span></span><span class="line"><span class="cl">OK </span></span><span class="line"><span class="cl">127.0.0.1:6379&gt; TS.CREATE telemetry:study:humidity LABELS room study <span class="nb">type</span> humidity </span></span><span class="line"><span class="cl">OK </span></span><span class="line"><span class="cl">127.0.0.1:6379&gt; TS.CREATE telemetry:kitchen:temperature LABELS room kitchen <span class="nb">type</span> temperature </span></span><span class="line"><span class="cl">OK </span></span><span class="line"><span class="cl">127.0.0.1:6379&gt; TS.CREATE telemetry:kitchen:humidity LABELS room kitchen <span class="nb">type</span> humidity </span></span><span class="line"><span class="cl">OK</span></span></code></pre> </div> <p> Find information about the time series for temperature in the kitchen. </p> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">127.0.0.1:6379&gt; TS.INFO telemetry:kitchen:temperature </span></span><span class="line"><span class="cl"> 1<span class="o">)</span> totalSamples </span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">0</span> </span></span><span class="line"><span class="cl"> 3<span class="o">)</span> memoryUsage </span></span><span class="line"><span class="cl"> 4<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">4246</span> </span></span><span class="line"><span class="cl"> 5<span class="o">)</span> firstTimestamp </span></span><span class="line"><span class="cl"> 6<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">0</span> </span></span><span class="line"><span class="cl"> 7<span class="o">)</span> lastTimestamp </span></span><span class="line"><span class="cl"> 8<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">0</span> </span></span><span class="line"><span class="cl"> 9<span class="o">)</span> retentionTime </span></span><span class="line"><span class="cl">10<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">0</span> </span></span><span class="line"><span class="cl">11<span class="o">)</span> chunkCount </span></span><span class="line"><span class="cl">12<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1</span> </span></span><span class="line"><span class="cl">13<span class="o">)</span> chunkSize </span></span><span class="line"><span class="cl">14<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">4096</span> </span></span><span class="line"><span class="cl">15<span class="o">)</span> chunkType </span></span><span class="line"><span class="cl">16<span class="o">)</span> compressed </span></span><span class="line"><span class="cl">17<span class="o">)</span> duplicatePolicy </span></span><span class="line"><span class="cl">18<span class="o">)</span> <span class="o">(</span>nil<span class="o">)</span> </span></span><span class="line"><span class="cl">19<span class="o">)</span> labels </span></span><span class="line"><span class="cl">20<span class="o">)</span> 1<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"room"</span> </span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"kitchen"</span> </span></span><span class="line"><span class="cl"> 2<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"type"</span> </span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"temperature"</span> </span></span><span class="line"><span class="cl">21<span class="o">)</span> sourceKey </span></span><span class="line"><span class="cl">22<span class="o">)</span> <span class="o">(</span>nil<span class="o">)</span> </span></span><span class="line"><span class="cl">23<span class="o">)</span> rules </span></span><span class="line"><span class="cl">24<span class="o">)</span> <span class="o">(</span>empty array<span class="o">)</span></span></span></code></pre> </div> <p> Query the time series using DEBUG to get more information about the chunks. </p> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">127.0.0.1:6379&gt; TS.INFO telemetry:kitchen:temperature DEBUG </span></span><span class="line"><span class="cl"> 1<span class="o">)</span> totalSamples </span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">0</span> </span></span><span class="line"><span class="cl"> 3<span class="o">)</span> memoryUsage </span></span><span class="line"><span class="cl"> 4<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">4246</span> </span></span><span class="line"><span class="cl"> 5<span class="o">)</span> firstTimestamp </span></span><span class="line"><span class="cl"> 6<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">0</span> </span></span><span class="line"><span class="cl"> 7<span class="o">)</span> lastTimestamp </span></span><span class="line"><span class="cl"> 8<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">0</span> </span></span><span class="line"><span class="cl"> 9<span class="o">)</span> retentionTime </span></span><span class="line"><span class="cl">10<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">0</span> </span></span><span class="line"><span class="cl">11<span class="o">)</span> chunkCount </span></span><span class="line"><span class="cl">12<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1</span> </span></span><span class="line"><span class="cl">13<span class="o">)</span> chunkSize </span></span><span class="line"><span class="cl">14<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">4096</span> </span></span><span class="line"><span class="cl">15<span class="o">)</span> chunkType </span></span><span class="line"><span class="cl">16<span class="o">)</span> compressed </span></span><span class="line"><span class="cl">17<span class="o">)</span> duplicatePolicy </span></span><span class="line"><span class="cl">18<span class="o">)</span> <span class="o">(</span>nil<span class="o">)</span> </span></span><span class="line"><span class="cl">19<span class="o">)</span> labels </span></span><span class="line"><span class="cl">20<span class="o">)</span> 1<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"room"</span> </span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"kitchen"</span> </span></span><span class="line"><span class="cl"> 2<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"type"</span> </span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"temperature"</span> </span></span><span class="line"><span class="cl">21<span class="o">)</span> sourceKey </span></span><span class="line"><span class="cl">22<span class="o">)</span> <span class="o">(</span>nil<span class="o">)</span> </span></span><span class="line"><span class="cl">23<span class="o">)</span> rules </span></span><span class="line"><span class="cl">24<span class="o">)</span> <span class="o">(</span>empty array<span class="o">)</span> </span></span><span class="line"><span class="cl">25<span class="o">)</span> keySelfName </span></span><span class="line"><span class="cl">26<span class="o">)</span> <span class="s2">"telemetry:kitchen:temperature"</span> </span></span><span class="line"><span class="cl">27<span class="o">)</span> Chunks </span></span><span class="line"><span class="cl">28<span class="o">)</span> 1<span class="o">)</span> 1<span class="o">)</span> startTimestamp </span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">0</span> </span></span><span class="line"><span class="cl"> 3<span class="o">)</span> endTimestamp </span></span><span class="line"><span class="cl"> 4<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">0</span> </span></span><span class="line"><span class="cl"> 5<span class="o">)</span> samples </span></span><span class="line"><span class="cl"> 6<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">0</span> </span></span><span class="line"><span class="cl"> 7<span class="o">)</span> size </span></span><span class="line"><span class="cl"> 8<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">4096</span> </span></span><span class="line"><span class="cl"> 9<span class="o">)</span> bytesPerSample </span></span><span class="line"><span class="cl"> 10<span class="o">)</span> <span class="s2">"inf"</span></span></span></code></pre> </div> </details> <h2 id="see-also"> See also </h2> <p> <a href="/docs/latest/commands/ts.range/"> <code> TS.RANGE </code> </a> | <a href="/docs/latest/commands/ts.queryindex/"> <code> TS.QUERYINDEX </code> </a> | <a href="/docs/latest/commands/ts.get/"> <code> TS.GET </code> </a> </p> <h2 id="related-topics"> Related topics </h2> <p> <a href="/docs/latest/develop/data-types/timeseries/"> RedisTimeSeries </a> </p> <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/ts.info/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/develop/interact/search-and-query/advanced-concepts/stopwords/.html
<section class="prose w-full py-12"> <h1> Stop words </h1> <p class="text-lg -mt-5 mb-10"> Stop words support </p> <p> Redis Stack has a default list of <a href="https://en.wikipedia.org/wiki/Stop_words"> stop words </a> . These are words that are usually so common that they do not add much information to search, but take up a lot of space and CPU time in the index. </p> <p> When indexing, stop words are discarded and not indexed. When searching, they are also ignored and treated as if they were not sent to the query processor. This is done when parsing the query. </p> <p> At the moment, the default stop word list applies to all full-text indexes in all languages and can be overridden manually at index creation time. </p> <h2 id="default-stop-word-list"> Default stop word list </h2> <p> The following words are treated as stop words by default: </p> <pre tabindex="0"><code> a, is, the, an, and, are, as, at, be, but, by, for, if, in, into, it, no, not, of, on, or, such, that, their, then, there, these, they, this, to, was, will, with </code></pre> <h2 id="overriding-the-default-stop-word-list"> Overriding the default stop word list </h2> <p> Stop words for an index can be defined (or disabled completely) on index creation using the <code> STOPWORDS </code> argument with the [ <a href="/docs/latest/commands/ft.create/"> <code> FT.CREATE </code> </a> command. </p> <p> The format is <code> STOPWORDS {number} {stopword} ... </code> where number is the number of stop words given. The <code> STOPWORDS </code> argument must come before the <code> SCHEMA </code> argument. For example: </p> <pre tabindex="0"><code>FT.CREATE myIndex STOPWORDS 3 foo bar baz SCHEMA title TEXT body TEXT </code></pre> <h2 id="disable-the-use-of-stop-words"> Disable the use of stop words </h2> <p> Disabling stop words completely can be done by passing <code> STOPWORDS 0 </code> to <a href="/docs/latest/commands/ft.create/"> <code> FT.CREATE </code> </a> . </p> <h2 id="avoiding-stop-word-detection-in-search-queries"> Avoiding stop word detection in search queries </h2> <p> In rare use cases, where queries are very long and are guaranteed by the client application not to contain stop words, it is possible to avoid checking for them when parsing the query. This saves some CPU time and is only worth it if the query has dozens or more terms in it. Using this without verifying that the query doesn't contain stop words might result in empty queries. </p> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/develop/interact/search-and-query/advanced-concepts/stopwords/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/ts.incrby/.html
<section class="prose w-full py-12"> <h1 class="command-name"> TS.INCRBY </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">TS.INCRBY key addend [TIMESTAMP timestamp] [RETENTION retentionPeriod] [ENCODING &lt;COMPRESSED|UNCOMPRESSED&gt;] [CHUNK_SIZE size] [DUPLICATE_POLICY policy] [IGNORE ignoreMaxTimediff ignoreMaxValDiff] [LABELS [label value ...]] </pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available in: </dt> <dd class="m-0"> <a href="/docs/stack"> Redis Stack </a> / <a href="/docs/data-types/timeseries"> TimeSeries 1.0.0 </a> </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(M) when M is the amount of compaction rules or O(1) with no compaction </dd> </dl> <p> Increase the value of the sample with the maximum existing timestamp, or create a new sample with a value equal to the value of the sample with the maximum existing timestamp with a given increment </p> <p> <a href="#examples"> Examples </a> </p> <h2 id="required-arguments"> Required arguments </h2> <details open=""> <summary> <code> key </code> </summary> <p> is key name for the time series. </p> </details> <details open=""> <summary> <code> addend </code> </summary> <p> is numeric value of the addend (double). </p> </details> <p> <note> <b> Notes </b> </note> </p> <ul> <li> When specified key does not exist, a new time series is created. </li> <li> You can use this command as a counter or gauge that automatically gets history as a time series. </li> <li> If a policy for handling duplicate samples ( <code> IGNORE </code> ) is defined for this time series - <code> TS.INCRBY </code> operations are affected as well (sample additions/modifications can be filtered). </li> <li> Explicitly adding samples to a compacted time series (using <a href="/docs/latest/commands/ts.add/"> <code> TS.ADD </code> </a> , <a href="/docs/latest/commands/ts.madd/"> <code> TS.MADD </code> </a> , <code> TS.INCRBY </code> , or <a href="/docs/latest/commands/ts.decrby/"> <code> TS.DECRBY </code> </a> ) may result in inconsistencies between the raw and the compacted data. The compaction process may override such samples. <br/> </li> </ul> <h2 id="optional-arguments"> Optional arguments </h2> <details open=""> <summary> <code> TIMESTAMP timestamp </code> </summary> <p> is Unix time (integer, in milliseconds) specifying the sample timestamp or <code> * </code> to set the sample timestamp to the Unix time of the server's clock. </p> <p> Unix time is the number of milliseconds that have elapsed since 00:00:00 UTC on 1 January 1970, the Unix epoch, without adjustments made due to leap seconds. </p> <p> <code> timestamp </code> must be equal to or higher than the maximum existing timestamp. When equal, the value of the sample with the maximum existing timestamp is increased. If it is higher, a new sample with a timestamp set to <code> timestamp </code> is created, and its value is set to the value of the sample with the maximum existing timestamp plus <code> addend </code> . </p> <p> If the time series is empty, the value is set to <code> addend </code> . </p> <p> When not specified, the timestamp is set to the Unix time of the server's clock. </p> </details> <details open=""> <summary> <code> RETENTION retentionPeriod </code> <p> is maximum retention period, compared to the maximum existing timestamp, in milliseconds. </p> <p> Use it only if you are creating a new time series. It is ignored if you are adding samples to an existing time series. See <code> RETENTION </code> in <a href="/docs/latest/commands/ts.create/"> <code> TS.CREATE </code> </a> . </p> </summary> </details> <details open=""> <summary> <code> ENCODING enc </code> </summary> <p> specifies the series sample encoding format. </p> <p> Use it only if you are creating a new time series. It is ignored if you are adding samples to an existing time series. See <code> ENCODING </code> in <a href="/docs/latest/commands/ts.create/"> <code> TS.CREATE </code> </a> . </p> </details> <details open=""> <summary> <code> CHUNK_SIZE size </code> </summary> <p> is memory size, in bytes, allocated for each data chunk. </p> <p> Use it only if you are creating a new time series. It is ignored if you are adding samples to an existing time series. See <code> CHUNK_SIZE </code> in <a href="/docs/latest/commands/ts.create/"> <code> TS.CREATE </code> </a> . </p> </details> <details open=""> <summary> <code> DUPLICATE_POLICY policy </code> </summary> <p> is policy for handling insertion ( <a href="/docs/latest/commands/ts.add/"> <code> TS.ADD </code> </a> and <a href="/docs/latest/commands/ts.madd/"> <code> TS.MADD </code> </a> ) of multiple samples with identical timestamps. </p> <p> Use it only if you are creating a new time series. It is ignored if you are adding samples to an existing time series. See <code> DUPLICATE_POLICY </code> in <a href="/docs/latest/commands/ts.create/"> <code> TS.CREATE </code> </a> . </p> </details> <details open=""> <summary> <code> IGNORE ignoreMaxTimediff ignoreMaxValDiff </code> </summary> <p> is the policy for handling duplicate samples. A new sample is considered a duplicate and is ignored if the following conditions are met: </p> <ul> <li> The time series is not a compaction; </li> <li> The time series' <code> DUPLICATE_POLICY </code> IS <code> LAST </code> ; </li> <li> The sample is added in-order ( <code> timestamp ≥ max_timestamp </code> ); </li> <li> The difference of the current timestamp from the previous timestamp ( <code> timestamp - max_timestamp </code> ) is less than or equal to <code> IGNORE_MAX_TIME_DIFF </code> ; </li> <li> The absolute value difference of the current value from the value at the previous maximum timestamp ( <code> abs(value - value_at_max_timestamp </code> ) is less than or equal to <code> IGNORE_MAX_VAL_DIFF </code> . </li> </ul> <p> where <code> max_timestamp </code> is the timestamp of the sample with the largest timestamp in the time series, and <code> value_at_max_timestamp </code> is the value at <code> max_timestamp </code> . </p> <p> When not specified: set to the global <a href="/docs/latest/develop/data-types/timeseries/configuration#ignore_max_time_diff-and-ignore_max_val_diff"> IGNORE_MAX_TIME_DIFF </a> and <a href="/docs/latest/develop/data-types/timeseries/configuration#ignore_max_time_diff-and-ignore_max_val_diff"> IGNORE_MAX_VAL_DIFF </a> , which are, by default, both set to 0. </p> <p> These parameters are used when creating a new time series to set the per-key parameters, and are ignored when called with an existing time series (the existing per-key configuration parameters are used). </p> </details> <details open=""> <summary> <code> LABELS [{label value}...] </code> </summary> <p> is set of label-value pairs that represent metadata labels of the key and serve as a secondary index. </p> <p> Use it only if you are creating a new time series. It is ignored if you are adding samples to an existing time series. See <code> LABELS </code> in <a href="/docs/latest/commands/ts.create/"> <code> TS.CREATE </code> </a> . </p> </details> <p> <note> <b> Notes </b> </note> </p> <ul> <li> You can use this command to create a new time series and add a sample to it in a single command. <code> RETENTION </code> , <code> ENCODING </code> , <code> CHUNK_SIZE </code> , <code> DUPLICATE_POLICY </code> , <code> IGNORE </code> , and <code> LABELS </code> are used only when creating a new time series, and ignored when adding or modifying samples in an existing time series. </li> <li> Setting <code> RETENTION </code> and <code> LABELS </code> introduces additional time complexity. </li> </ul> <h2 id="return-value"> Return value </h2> <p> Returns one of these replies: </p> <ul> <li> <a href="/docs/latest/develop/reference/protocol-spec/#integers"> Integer reply </a> - the timestamp of the upserted sample. If the sample is ignored (See <code> IGNORE </code> in <a href="/docs/latest/commands/ts.create/"> <code> TS.CREATE </code> </a> ), the reply will be the largest timestamp in the time series. </li> <li> [] on error (invalid arguments, wrong key type, etc.), or when <code> timestamp </code> is not equal to or higher than the maximum existing timestamp </li> </ul> <h2 id="examples"> Examples </h2> <details open=""> <summary> <b> Store sum of data from several sources </b> </summary> <p> Suppose you are getting number of orders or total income per minute from several points of sale, and you want to store only the combined value. Call TS.INCRBY for each point-of-sale report. </p> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">127.0.0.1:6379&gt; TS.INCRBY a <span class="m">232</span> TIMESTAMP 1657811829000 // point-of-sale <span class="c1">#1</span> </span></span><span class="line"><span class="cl"><span class="o">(</span>integer<span class="o">)</span> <span class="m">1657811829000</span> </span></span><span class="line"><span class="cl">127.0.0.1:6379&gt; TS.INCRBY a <span class="m">157</span> TIMESTAMP 1657811829000 // point-of-sale <span class="c1">#2</span> </span></span><span class="line"><span class="cl"><span class="o">(</span>integer<span class="o">)</span> <span class="m">1657811829000</span> </span></span><span class="line"><span class="cl">127.0.0.1:6379&gt; TS.INCRBY a <span class="m">432</span> TIMESTAMP 1657811829000 // point-of-sale <span class="c1">#3</span> </span></span><span class="line"><span class="cl"><span class="o">(</span>integer<span class="o">)</span> <span class="m">1657811829000</span></span></span></code></pre> </div> <p> Note that the timestamps must arrive in non-decreasing order. </p> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">127.0.0.1:6379&gt; ts.incrby a <span class="m">100</span> TIMESTAMP <span class="m">50</span> </span></span><span class="line"><span class="cl"><span class="o">(</span>error<span class="o">)</span> TSDB: timestamp must be equal to or higher than the maximum existing timestamp</span></span></code></pre> </div> <p> You can achieve similar results without such protection using <code> TS.ADD key timestamp value ON_DUPLICATE sum </code> . </p> </details> <details open=""> <summary> <b> Count sensor captures </b> </summary> <p> Suppose a sensor ticks whenever a car is passed on a road, and you want to count occurrences. Whenever you get a tick from the sensor you can simply call: </p> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">127.0.0.1:6379&gt; TS.INCRBY a <span class="m">1</span> </span></span><span class="line"><span class="cl"><span class="o">(</span>integer<span class="o">)</span> <span class="m">1658431553109</span></span></span></code></pre> </div> <p> The timestamp is filled automatically. </p> </details> <h2 id="see-also"> See also </h2> <p> <a href="/docs/latest/commands/ts.decrby/"> <code> TS.DECRBY </code> </a> | <a href="/docs/latest/commands/ts.create/"> <code> TS.CREATE </code> </a> </p> <h2 id="related-topics"> Related topics </h2> <p> <a href="/docs/latest/develop/data-types/timeseries/"> RedisTimeSeries </a> </p> <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/ts.incrby/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/ts.deleterule/.html
<section class="prose w-full py-12"> <h1 class="command-name"> TS.DELETERULE </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">TS.DELETERULE sourceKey destKey </pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available in: </dt> <dd class="m-0"> <a href="/docs/stack"> Redis Stack </a> / <a href="/docs/data-types/timeseries"> TimeSeries 1.0.0 </a> </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(1) </dd> </dl> <p> Delete a compaction rule </p> <h2 id="required-arguments"> Required arguments </h2> <details open=""> <summary> <code> sourceKey </code> </summary> <p> is key name for the source time series. </p> </details> <details open=""> <summary> <code> destKey </code> </summary> <p> is key name for destination (compacted) time series. </p> </details> <p> <note> <b> Note: </b> This command does not delete the compacted series. </note> </p> <h2 id="return-value"> Return value </h2> <p> Returns one of these replies: </p> <ul> <li> <a href="/docs/latest/develop/reference/protocol-spec/#simple-strings"> Simple string reply </a> - <code> OK </code> if executed correctly </li> <li> [] on error (invalid arguments, etc.), or when such rule does not exist </li> </ul> <h2 id="see-also"> See also </h2> <p> <a href="/docs/latest/commands/ts.createrule/"> <code> TS.CREATERULE </code> </a> </p> <h2 id="related-topics"> Related topics </h2> <p> <a href="/docs/latest/develop/data-types/timeseries/"> RedisTimeSeries </a> </p> <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/ts.deleterule/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/release-notes/rs-6-0-12-january-2021/.html
<section class="prose w-full py-12 max-w-none"> <h1> Redis Enterprise Software Release Notes 6.0.12 (January 2021) </h1> <p class="text-lg -mt-5 mb-10"> Distribute synchronization across nodes for Active-Active and Active-Passive databases. Disable internal services to free memory. User accounts support password rotation. Module depdencies automatically installed. Syncer process recovery. </p> <p> <a href="https://redislabs.com/download-center/#downloads"> Redis Enterprise Software (RS) 6.0.12 </a> is now available! This version includes the following new features and improvements: </p> <ul> <li> <a href="/docs/latest/operate/rs/databases/active-active/#syncer-process"> Synchronization </a> can now be <a href="/docs/latest/operate/rs/databases/active-active/synchronization-mode/"> distributed across the nodes </a> of Active-Active or Active-Passive databases </li> <li> You can <a href="/docs/latest/operate/rs/clusters/optimize/turn-off-services/"> disable several internal RS services </a> to free up more memory </li> <li> User accounts can have multiple passwords to allow for <a href="/docs/latest/operate/rs/security/access-control/manage-passwords/rotate-passwords/"> password rotation </a> </li> <li> <a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/install/add-module-to-cluster/#rest-api-method"> Dependencies are automatically installed </a> when you add modules to a cluster </li> <li> <a href="/docs/latest/operate/rs/networking/port-configurations/"> Envoy replaces NGINX </a> for internal cluster administration </li> <li> Automatic recovery of the <a href="/docs/latest/operate/rs/databases/active-active/#syncer-process"> syncer process </a> s from out-of-memory (preview mode) </li> </ul> <p> And other functional and stability improvements. </p> <h2 id="version-information"> Version information </h2> <h3 id="upgrade-instructions"> Upgrade instructions </h3> <ul> <li> Follow <a href="/docs/latest/operate/rs/installing-upgrading/upgrading/"> these instructions </a> for upgrading to RS 6.0.12 from RS 5.4.0 and above. </li> <li> For Active-Active deployments, this release requires that you <a href="/docs/latest/operate/rs/installing-upgrading/upgrading/upgrade-active-active/"> upgrade the CRDB featureset version </a> . </li> </ul> <h3 id="product-lifecycle-information"> Product lifecycle information </h3> <ul> <li> End of Life (EOL) for Redis Enterprise Software 6.0 and previous RS versions, can be found <a href="/docs/latest/operate/rs/installing-upgrading/product-lifecycle/"> here </a> . </li> <li> EOL for Redis modules can be found <a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/modules-lifecycle/#modules-endoflife-schedule"> here </a> . </li> </ul> <h3 id="deprecation-notice"> Deprecation Notice </h3> <ul> <li> Support for RS 5.4.X ended on December 31, 2020. </li> <li> Support for Red Hat Enterprise Linux 6 and Oracle Linux 6 and Ubuntu 14.04 (Trusty) operating systems platforms ended on November 30, 2020. </li> <li> This is the last RS version that supports direct upgrades from versions below 5.6.0. </li> <li> This is the last RS version that supports Active-Active protocol version below 1 and featureset version below 1. </li> </ul> <h2 id="new-features"> New Features </h2> <h4 id="distributed-syncer"> Distributed Syncer </h4> <p> The syncer process now supports running in a <a href="/docs/latest/operate/rs/databases/active-active/synchronization-mode/"> distributed mode </a> . This option can improve the latency for Active-Active databases with a very high throughput profile. You can configure a replicated database to use distributed synchronization so that any available proxy endpoint can manage synchronization traffic. </p> <h4 id="disabling-rs-services-to-free-memory"> Disabling RS services to free memory </h4> <p> Redis Software users can now use the REST API to <a href="/docs/latest/operate/rs/clusters/optimize/turn-off-services/"> disable the following services </a> : </p> <ul> <li> cm_server </li> <li> mdns_server </li> <li> pdns_server </li> <li> stats_archiver </li> <li> saslauthd </li> <li> crdb_coordinator </li> <li> crdb_worker </li> </ul> <p> Once disabled, services are not monitored and controlled by the supervisord. </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Warning: </div> This feature can cause unintended results if the cluster relies on the disabled services. To make sure you understand the impact of disabled services, test the system in a lab environment before you deploy in production. </div> </div> <h4 id="support-for-multiple-passwords"> Support for multiple passwords </h4> <p> For users of Redis 6 and RS 6.0 and above, you can now add more security to your password management by maintaining multiple passwords for a user to allow seamless password rotation. </p> <p> As of RS 6.0, you can assign specific data access permissions (Redis ACLs) and cluster administration permissions to users. Password rotation is especially helpful so that you can do a rolling update of the passwords in the application clients that connect to the Redis databases. </p> <p> In this version, you can only configure multiple passwords <a href="/docs/latest/operate/rs/security/access-control/manage-passwords/rotate-passwords/"> using the REST API </a> . </p> <h4 id="redis-modules-dependencies-management"> Redis Modules dependencies management </h4> <p> RedisGears GA and RedisAI GA require Redis Software to fetch and manage external dependencies. Modules declare dependencies at release time in their ramp file. </p> <p> In this version of RS, these dependencies are installed by Redis Software when the module is added to the cluster. The master node downloads the required dependencies and prompts the other nodes to copy the dependencies from the master node. When all dependency requirements are satisfied, the module installation is complete. New nodes to the cluster also automatically install the dependencies. </p> <h4 id="syncer-automatic-recovery-from-out-of-memory-preview-mode"> Syncer automatic recovery from out-of-memory (Preview mode) </h4> <p> For Active-Active databases, the syncer process gracefully recovers from an out of memory (OOM) state. </p> <p> Although Active-Active synchronization is bi-directional, in each direction we can define a source instance and a destination instance. When a destination instance (that is, the instance running the syncer process) gets OOM, the syncer process attempts to automatically recover the data synchronization when memory becomes available. </p> <p> This is a configurable option and currently under preview mode. This behavior will be GA and set as default in the next RS version. </p> <p> To enable the syncer automatic recovery, do these steps on each participating cluster: </p> <ol> <li> <p> <a href="/docs/latest/operate/rs/installing-upgrading/upgrading/upgrade-active-active/"> Upgrade the featureset version </a> to <code> 3 </code> . </p> </li> <li> <p> Enable the syncer automatic recovery using the REST API: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">curl -v -k -u &lt;username&gt;:&lt;password&gt; -X PUT -H “Content-Type: application/json” -d ‘<span class="o">{</span>crdt_syncer_auto_oom_unlatch”:true<span class="o">}</span>’ http://&lt;cluster_address&gt;:8080/v1/bdbs/&lt;database_ID&gt; </span></span></code></pre> </div> </li> </ol> <p> The syncer process restarts to with automatic recovery on. </p> <h2 id="redis-modules"> Redis modules </h2> <p> The following GA releases of Redis modules are bundled with RS 6.0.12: </p> <ul> <li> <a href="https://redislabs.com/redis-enterprise/redis-search/"> RediSearch </a> , version <a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/redisearch/redisearch-2.0-release-notes/"> 2.0.6 </a> </li> <li> <a href="https://redislabs.com/redis-enterprise/redis-json/"> RedisJSON </a> , version <a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/redisjson/redisjson-1.0-release-notes/"> 1.0.4 </a> </li> <li> <a href="https://redislabs.com/redis-enterprise/redis-graph/"> RedisGraph </a> , version <a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/redisgraph/"> 2.2.11 </a> </li> <li> <a href="https://redislabs.com/redis-enterprise/redis-time-series/"> RedisTimeSeries </a> , version <a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/redistimeseries/"> 1.4.7 </a> </li> <li> <a href="https://redislabs.com/redis-enterprise/redis-bloom/"> RedisBloom </a> , version <a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/redisbloom/redisbloom-2.2-release-notes/"> 2.2.4 </a> </li> </ul> <p> To use the updated modules with a database, you must <a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/install/upgrade-module/"> upgrade the module on the database </a> . </p> <h2 id="additional-capabilities"> Additional capabilities </h2> <ul> <li> RS 6.0.12 includes open source Redis 6.0.6. For more information about Redis 6.0.6, check out the <a href="https://raw.githubusercontent.com/redis/redis/6.0.6/00-RELEASENOTES"> release notes </a> . </li> <li> The bundled Nginx version was updated from version 1.16.0 to 1.18.0. </li> <li> The crdb-cli syntax to remove an instance is changed from <code> remove-instance [--ordered|--unordered] </code> to <code> remove-instance [--force|--no-force] </code> . </li> </ul> <h2 id="important-fixes"> Important fixes </h2> <ul> <li> RS45627, RS47382 - Fixed bugs causing clients to disconnect when using XREAD and XREADGROUP commands in blocking mode on other clients’ connections. </li> <li> RS44656 - Fixed a bug causing TLS mode for clients connections to toggle between ‘all communication’ to ‘for crdb communication only’ when performing a global configuration change. </li> <li> RS42587 - Fixed a bug in the web UI console if the FQDN of the cluster is a substring of the FQDN of a participating cluster </li> <li> RS49404 - Fixed a bug in for upgrades with custom directories that prevent users from creating databases via the web UI console. </li> <li> RS43961 - bigkeys command fixed to handle non-printable key names </li> <li> RS45707 - Fixed a bug that caused RCP (Redis Cloud Pro) databases to reject connections while resharding the database. </li> <li> RS51144 - Fixed a bug in the syncer process that was stopping synchronization between all instances in some scenarios of network disconnection of one or more participating clusters. </li> </ul> <p> with 6.0.12-58: </p> <ul> <li> RS50865 - Fixed a bug causing rladmin change master node to fail when performed after a prior successful master change. </li> <li> RS51359 - Fixed a memory leak on replica shards in Active-Active databases with replication and AOF for persistence. </li> <li> RS52363 - Updated PUB/SUB max message value size from 64KB to 512MB </li> </ul> <h2 id="known-limitations"> Known limitations </h2> <p> -RS81463 - A shard may crash when resharding an Active-Active database with Auto Tiering . Specifically, the shard will crash when volatile keys or Active-Active tombstone keys reside in Flash memory. </p> <h3 id="installation-limitations"> Installation limitations </h3> <p> Several Redis Enterprise Software installation reference files are installed to the directory <code> /etc/opt/redislabs/ </code> even if you use <a href="/docs/latest/operate/rs/installing-upgrading/install/customize-install-directories/"> custom installation directories </a> . </p> <p> As a workaround to install Redis Enterprise Software without using any root directories, do the following before installing Redis Enterprise Software: </p> <ol> <li> <p> Create all custom, non-root directories you want to use with Redis Enterprise Software. </p> </li> <li> <p> Mount <code> /etc/opt/redislabs </code> to one of the custom, non-root directories. </p> </li> </ol> <h4 id="upgrade"> Upgrade </h4> <ul> <li> <a href="/docs/latest/operate/rs/release-notes/legacy-release-notes/rs-5-4-2-april-2019/"> RS 5.4.2 </a> introduced new Active-Active Redis Database capabilities that improve its compatibility with open source Redis. Now the string data-type in Active-Active Redis Database is implicitly and dynamically typed, just like open source Redis. To use the new capabilities on nodes that are upgraded from version RS 5.4.2 or lower, you must <a href="/docs/latest/operate/rs/installing-upgrading/upgrading/#upgrading-crdbs"> upgrade the Active-Active Redis Database protocol </a> . </li> <li> When you upgrade an Active-Active Redis with active AOF from version <a href="/docs/latest/operate/rs/release-notes/legacy-release-notes/rs-5-4-2-april-2019/"> RS 5.4.2 </a> or earlier to version <a href="/docs/latest/operate/rs/release-notes/legacy-release-notes/rs-5-4-4-june-2019/"> RS 5.4.4 </a> or later: <ul> <li> If replication is enabled, you must run the BGREWRITEAOF command on all replica shards after the upgrade. </li> <li> If replication is not enabled, you must run the BGREWRITEAOF command on all shards after the upgrade. </li> </ul> </li> <li> Node upgrade fails if the SSL certificates were configured in version 5.0.2 or above by manually updating the certificates on the disk instead of <a href="/docs/latest/operate/rs/security/certificates/updating-certificates/"> updating them through the API </a> . For assistance with this issue, contact Support. </li> <li> Starting from <a href="/docs/latest/operate/rs/release-notes/legacy-release-notes/rs-5-4-2-april-2019/"> RS 5.4.2 </a> , to preserve the current Redis major.minor version during database upgrade you must use the keep_redis_version option instead of keep_current_version. </li> </ul> <h4 id="redis-commands"> Redis commands </h4> <ul> <li> The capability of disabling specific Redis commands does not work on commands specific to Redis modules. </li> <li> CLIENT UNBLOCK command is not supported in RS 5.4 and above </li> <li> Starting from RS 5.4.2 and after upgrading the CRDB, TYPE commands for string data-type in CRDBs return "string" (OSS Redis standard). </li> </ul> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/release-notes/rs-6-0-12-january-2021/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/security/access-control/create-combined-roles/.html
<section class="prose w-full py-12 max-w-none"> <h1> Create roles with combined access </h1> <p class="text-lg -mt-5 mb-10"> Create roles with both cluster and database access. </p> <p> To create a role that grants database access privileges and allows access to the Cluster Management UI and REST API: </p> <ol> <li> <p> <a href="#define-redis-acls"> Define Redis ACLs </a> that determine database access privileges. </p> </li> <li> <p> <a href="#create-role"> Create a role with ACLs </a> added and choose a <strong> Cluster management role </strong> other than <strong> None </strong> . </p> </li> </ol> <h2 id="define-redis-acls"> Define Redis ACLs </h2> <p> To define a Redis ACL rule that you can assign to a role: </p> <ol> <li> <p> From <strong> Access Control &gt; Redis ACLs </strong> , you can either: </p> <ul> <li> <p> Point to a Redis ACL and select <a href="/docs/latest/images/rs/buttons/edit-button.png#no-click" sdata-lightbox="/images/rs/buttons/edit-button.png#no-click"> <img alt="The Edit button" class="inline" src="/docs/latest/images/rs/buttons/edit-button.png#no-click" width="25px"/> </a> to edit an existing Redis ACL. </p> </li> <li> <p> Select <strong> + Add Redis ACL </strong> to create a new Redis ACL. </p> </li> </ul> </li> <li> <p> Enter a descriptive name for the Redis ACL. This will be used to associate the ACL rule with the role. </p> </li> <li> <p> Define the ACL rule. For more information about Redis ACL rules and syntax, see the <a href="/docs/latest/operate/rs/security/access-control/redis-acl-overview/"> Redis ACL overview </a> . </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> The <strong> ACL builder </strong> does not support selectors and key permissions. Use <strong> Free text command </strong> to manually define them instead. </div> </div> </li> <li> <p> Select <strong> Save </strong> . </p> </li> </ol> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> For multi-key commands on multi-slot keys, the return value is <code> failure </code> , but the command runs on the keys that are allowed. </div> </div> <h2 id="create-role"> Create roles with ACLs and cluster access </h2> <p> To create a role that grants database access privileges and allows access to the Cluster Management UI and REST API: </p> <ol> <li> <p> From <strong> Access Control </strong> &gt; <strong> Roles </strong> , you can: </p> <ul> <li> <p> Point to a role and select <a href="/docs/latest/images/rs/buttons/edit-button.png#no-click" sdata-lightbox="/images/rs/buttons/edit-button.png#no-click"> <img alt="The Edit button" class="inline" src="/docs/latest/images/rs/buttons/edit-button.png#no-click" width="25px"/> </a> to edit an existing role. </p> </li> <li> <p> Select <strong> + Add role </strong> to create a new role. </p> </li> </ul> <a href="/docs/latest/images/rs/access-control-role-panel.png" sdata-lightbox="/images/rs/access-control-role-panel.png"> <img alt="Add role with name" src="/docs/latest/images/rs/access-control-role-panel.png"/> </a> </li> <li> <p> Enter a descriptive name for the role. This will be used to reference the role when configuring users. </p> </li> <li> <p> Choose a <strong> Cluster management role </strong> other than <strong> None </strong> . For details about permissions granted by each role, see <a href="/docs/latest/operate/rs/security/access-control/create-cluster-roles/#cluster-manager-ui-permissions"> Cluster Manager UI permissions </a> and <a href="/docs/latest/operate/rs/references/rest-api/permissions/"> REST API permissions </a> . </p> <a href="/docs/latest/images/rs/screenshots/access-control/rbac-create-combined-role-select-cm-role.png" sdata-lightbox="/images/rs/screenshots/access-control/rbac-create-combined-role-select-cm-role.png"> <img alt="Add role with name" src="/docs/latest/images/rs/screenshots/access-control/rbac-create-combined-role-select-cm-role.png"/> </a> </li> <li> <p> Select <strong> + Add ACL </strong> . </p> <a href="/docs/latest/images/rs/access-control-role-acl.png" sdata-lightbox="/images/rs/access-control-role-acl.png"> <img alt="Add role database acl" src="/docs/latest/images/rs/access-control-role-acl.png"/> </a> </li> <li> <p> Choose a Redis ACL and databases to associate with the role. </p> <a href="/docs/latest/images/rs/screenshots/access-control/access-control-role-databases.png" sdata-lightbox="/images/rs/screenshots/access-control/access-control-role-databases.png"> <img alt="Add databases to access" src="/docs/latest/images/rs/screenshots/access-control/access-control-role-databases.png"/> </a> </li> <li> <p> Select the check mark <a href="/docs/latest/images/rs/buttons/checkmark-button.png#no-click" sdata-lightbox="/images/rs/buttons/checkmark-button.png#no-click"> <img alt="The Check button" class="inline" src="/docs/latest/images/rs/buttons/checkmark-button.png#no-click" width="25px"/> </a> to confirm. </p> </li> <li> <p> Select <strong> Save </strong> . </p> <a href="/docs/latest/images/rs/screenshots/access-control/rbac-save-combined-role.png" sdata-lightbox="/images/rs/screenshots/access-control/rbac-save-combined-role.png"> <img alt="Add databases to access" src="/docs/latest/images/rs/screenshots/access-control/rbac-save-combined-role.png"/> </a> </li> </ol> <p> You can <a href="/docs/latest/operate/rs/security/access-control/create-users/#assign-roles-to-users"> assign the new role to users </a> to grant database access and access to the Cluster Manager UI and REST API. </p> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/security/access-control/create-combined-roles/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/scan/.html
<section class="prose w-full py-12"> <h1 class="command-name"> SCAN </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">SCAN cursor [MATCH pattern] [COUNT count] [TYPE type]</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available since: </dt> <dd class="m-0"> 2.8.0 </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(1) for every call. O(N) for a complete iteration, including enough command calls for the cursor to return back to 0. N is the number of elements inside the collection. </dd> <dt class="font-semibold text-redis-ink-900 m-0"> ACL categories: </dt> <dd class="m-0"> <code> @keyspace </code> <span class="mr-1 last:hidden"> , </span> <code> @read </code> <span class="mr-1 last:hidden"> , </span> <code> @slow </code> <span class="mr-1 last:hidden"> , </span> </dd> </dl> <p> The <code> SCAN </code> command and the closely related commands <a href="/docs/latest/commands/sscan/"> <code> SSCAN </code> </a> , <a href="/docs/latest/commands/hscan/"> <code> HSCAN </code> </a> and <a href="/docs/latest/commands/zscan/"> <code> ZSCAN </code> </a> are used in order to incrementally iterate over a collection of elements. </p> <ul> <li> <code> SCAN </code> iterates the set of keys in the currently selected Redis database. </li> <li> <a href="/docs/latest/commands/sscan/"> <code> SSCAN </code> </a> iterates elements of Sets types. </li> <li> <a href="/docs/latest/commands/hscan/"> <code> HSCAN </code> </a> iterates fields of Hash types and their associated values. </li> <li> <a href="/docs/latest/commands/zscan/"> <code> ZSCAN </code> </a> iterates elements of Sorted Set types and their associated scores. </li> </ul> <p> Since these commands allow for incremental iteration, returning only a small number of elements per call, they can be used in production without the downside of commands like <a href="/docs/latest/commands/keys/"> <code> KEYS </code> </a> or <a href="/docs/latest/commands/smembers/"> <code> SMEMBERS </code> </a> that may block the server for a long time (even several seconds) when called against big collections of keys or elements. </p> <p> However while blocking commands like <a href="/docs/latest/commands/smembers/"> <code> SMEMBERS </code> </a> are able to provide all the elements that are part of a Set in a given moment, The SCAN family of commands only offer limited guarantees about the returned elements since the collection that we incrementally iterate can change during the iteration process. </p> <p> Note that <code> SCAN </code> , <a href="/docs/latest/commands/sscan/"> <code> SSCAN </code> </a> , <a href="/docs/latest/commands/hscan/"> <code> HSCAN </code> </a> and <a href="/docs/latest/commands/zscan/"> <code> ZSCAN </code> </a> all work very similarly, so this documentation covers all four commands. However an obvious difference is that in the case of <a href="/docs/latest/commands/sscan/"> <code> SSCAN </code> </a> , <a href="/docs/latest/commands/hscan/"> <code> HSCAN </code> </a> and <a href="/docs/latest/commands/zscan/"> <code> ZSCAN </code> </a> the first argument is the name of the key holding the Set, Hash or Sorted Set value. The <code> SCAN </code> command does not need any key name argument as it iterates keys in the current database, so the iterated object is the database itself. </p> <h2 id="scan-basic-usage"> SCAN basic usage </h2> <p> SCAN is a cursor based iterator. This means that at every call of the command, the server returns an updated cursor that the user needs to use as the cursor argument in the next call. </p> <p> An iteration starts when the cursor is set to 0, and terminates when the cursor returned by the server is 0. The following is an example of SCAN iteration: </p> <pre tabindex="0"><code>&gt; scan 0 1) "17" 2) 1) "key:12" 2) "key:8" 3) "key:4" 4) "key:14" 5) "key:16" 6) "key:17" 7) "key:15" 8) "key:10" 9) "key:3" 10) "key:7" 11) "key:1" &gt; scan 17 1) "0" 2) 1) "key:5" 2) "key:18" 3) "key:0" 4) "key:2" 5) "key:19" 6) "key:13" 7) "key:6" 8) "key:9" 9) "key:11" </code></pre> <p> In the example above, the first call uses zero as a cursor, to start the iteration. The second call uses the cursor returned by the previous call as the first element of the reply, that is, 17. </p> <p> As you can see the <strong> SCAN return value </strong> is an array of two values: the first value is the new cursor to use in the next call, the second value is an array of elements. </p> <p> Since in the second call the returned cursor is 0, the server signaled to the caller that the iteration finished, and the collection was completely explored. Starting an iteration with a cursor value of 0, and calling <code> SCAN </code> until the returned cursor is 0 again is called a <strong> full iteration </strong> . </p> <h2 id="return-value"> Return value </h2> <p> <code> SCAN </code> , <a href="/docs/latest/commands/sscan/"> <code> SSCAN </code> </a> , <a href="/docs/latest/commands/hscan/"> <code> HSCAN </code> </a> and <a href="/docs/latest/commands/zscan/"> <code> ZSCAN </code> </a> return a two element multi-bulk reply, where the first element is a string representing an unsigned 64 bit number (the cursor), and the second element is a multi-bulk with an array of elements. </p> <ul> <li> <code> SCAN </code> array of elements is a list of keys. </li> <li> <a href="/docs/latest/commands/sscan/"> <code> SSCAN </code> </a> array of elements is a list of Set members. </li> <li> <a href="/docs/latest/commands/hscan/"> <code> HSCAN </code> </a> array of elements contain two elements, a field and a value, for every returned element of the Hash. </li> <li> <a href="/docs/latest/commands/zscan/"> <code> ZSCAN </code> </a> array of elements contain two elements, a member and its associated score, for every returned element of the Sorted Set. </li> </ul> <h2 id="scan-guarantees"> Scan guarantees </h2> <p> The <code> SCAN </code> command, and the other commands in the <code> SCAN </code> family, are able to provide to the user a set of guarantees associated to full iterations. </p> <ul> <li> A full iteration always retrieves all the elements that were present in the collection from the start to the end of a full iteration. This means that if a given element is inside the collection when an iteration is started, and is still there when an iteration terminates, then at some point <code> SCAN </code> returned it to the user. </li> <li> A full iteration never returns any element that was NOT present in the collection from the start to the end of a full iteration. So if an element was removed before the start of an iteration, and is never added back to the collection for all the time an iteration lasts, <code> SCAN </code> ensures that this element will never be returned. </li> </ul> <p> However because <code> SCAN </code> has very little state associated (just the cursor) it has the following drawbacks: </p> <ul> <li> A given element may be returned multiple times. It is up to the application to handle the case of duplicated elements, for example only using the returned elements in order to perform operations that are safe when re-applied multiple times. </li> <li> Elements that were not constantly present in the collection during a full iteration, may be returned or not: it is undefined. </li> </ul> <h2 id="number-of-elements-returned-at-every-scan-call"> Number of elements returned at every SCAN call </h2> <p> <code> SCAN </code> family functions do not guarantee that the number of elements returned per call are in a given range. The commands are also allowed to return zero elements, and the client should not consider the iteration complete as long as the returned cursor is not zero. </p> <p> However the number of returned elements is reasonable, that is, in practical terms <code> SCAN </code> may return a maximum number of elements in the order of a few tens of elements when iterating a large collection, or may return all the elements of the collection in a single call when the iterated collection is small enough to be internally represented as an encoded data structure (this happens for small Sets, Hashes and Sorted Sets). </p> <p> However there is a way for the user to tune the order of magnitude of the number of returned elements per call using the <strong> COUNT </strong> option. </p> <h2 id="the-count-option"> The COUNT option </h2> <p> While <code> SCAN </code> does not provide guarantees about the number of elements returned at every iteration, it is possible to empirically adjust the behavior of <code> SCAN </code> using the <strong> COUNT </strong> option. Basically with COUNT the user specifies the <em> amount of work that should be done at every call in order to retrieve elements from the collection </em> . This is <strong> just a hint </strong> for the implementation, however generally speaking this is what you could expect most of the times from the implementation. </p> <ul> <li> The default <code> COUNT </code> value is 10. </li> <li> When iterating the key space, or a Set, Hash or Sorted Set that is big enough to be represented by a hash table, assuming no <strong> MATCH </strong> option is used, the server will usually return <em> count </em> or a few more than <em> count </em> elements per call. Please check the <em> why SCAN may return all the elements at once </em> section later in this document. </li> <li> When iterating Sets encoded as intsets (small sets composed of just integers), or Hashes and Sorted Sets encoded as ziplists (small hashes and sets composed of small individual values), usually all the elements are returned in the first <code> SCAN </code> call regardless of the <code> COUNT </code> value. </li> </ul> <p> Important: <strong> there is no need to use the same COUNT value </strong> for every iteration. The caller is free to change the count from one iteration to the other as required, as long as the cursor passed in the next call is the one obtained in the previous call to the command. </p> <h2 id="the-match-option"> The MATCH option </h2> <p> It is possible to only iterate elements matching a given glob-style pattern, similarly to the behavior of the <a href="/docs/latest/commands/keys/"> <code> KEYS </code> </a> command that takes a pattern as its only argument. </p> <p> To do so, just append the <code> MATCH &lt;pattern&gt; </code> arguments at the end of the <code> SCAN </code> command (it works with all the <code> SCAN </code> family commands). </p> <p> This is an example of iteration using <strong> MATCH </strong> : </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="cmds_generic-stepscan1"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_cmds_generic-stepscan1" name="cmds_generic-stepscan1" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_cmds_generic-stepscan1" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-cmds_generic-stepscan1" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_cmds_generic-stepscan1" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; sadd myset 1 2 3 foo foobar feelsgood </span></span><span class="line hl"><span class="cl">(integer) 6 </span></span><span class="line hl"><span class="cl">&gt; sscan myset 0 match f* </span></span><span class="line hl"><span class="cl">1) "0" </span></span><span class="line hl"><span class="cl">2) 1) "foo" </span></span><span class="line hl"><span class="cl"> 2) "feelsgood" </span></span><span class="line hl"><span class="cl"> 3) "foobar"</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_cmds_generic-stepscan1')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_cmds_generic-stepscan1" name="cmds_generic-stepscan1" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_cmds_generic-stepscan1" title="Open example"> Python </label> <div aria-labelledby="tab-cmds_generic-stepscan1" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_cmds_generic-stepscan1" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"key1"</span><span class="p">,</span> <span class="s2">"Hello"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"key2"</span><span class="p">,</span> <span class="s2">"World"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"key1"</span><span class="p">,</span> <span class="s2">"key2"</span><span class="p">,</span> <span class="s2">"key3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">,</span> <span class="s2">"Hello"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">expire</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ttl</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; 10</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">,</span> <span class="s2">"Hello World"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ttl</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; -1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">expire</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="n">xx</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ttl</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; -1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">expire</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="n">nx</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ttl</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; 10</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">,</span> <span class="s2">"Hello"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">expire</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ttl</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; 10</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"myset"</span><span class="p">,</span> <span class="o">*</span><span class="nb">set</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="s2">"foo"</span><span class="p">,</span> <span class="s2">"foobar"</span><span class="p">,</span> <span class="s2">"feelsgood"</span><span class="p">]))</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="c1"># &gt;&gt;&gt; 6</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">r</span><span class="o">.</span><span class="n">sscan_iter</span><span class="p">(</span><span class="s2">"myset"</span><span class="p">,</span> <span class="n">match</span><span class="o">=</span><span class="s2">"f*"</span><span class="p">))</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="c1"># &gt;&gt;&gt; ['foobar', 'foo', 'feelsgood']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">cursor</span><span class="p">,</span> <span class="n">key</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">scan</span><span class="p">(</span><span class="n">cursor</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">match</span><span class="o">=</span><span class="s1">'*11*'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">cursor</span><span class="p">,</span> <span class="n">key</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">cursor</span><span class="p">,</span> <span class="n">key</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">scan</span><span class="p">(</span><span class="n">cursor</span><span class="p">,</span> <span class="n">match</span><span class="o">=</span><span class="s1">'*11*'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">cursor</span><span class="p">,</span> <span class="n">key</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">cursor</span><span class="p">,</span> <span class="n">key</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">scan</span><span class="p">(</span><span class="n">cursor</span><span class="p">,</span> <span class="n">match</span><span class="o">=</span><span class="s1">'*11*'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">cursor</span><span class="p">,</span> <span class="n">key</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">cursor</span><span class="p">,</span> <span class="n">key</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">scan</span><span class="p">(</span><span class="n">cursor</span><span class="p">,</span> <span class="n">match</span><span class="o">=</span><span class="s1">'*11*'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">cursor</span><span class="p">,</span> <span class="n">key</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">cursor</span><span class="p">,</span> <span class="n">keys</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">scan</span><span class="p">(</span><span class="n">cursor</span><span class="p">,</span> <span class="n">match</span><span class="o">=</span><span class="s1">'*11*'</span><span class="p">,</span> <span class="n">count</span><span class="o">=</span><span class="mi">1000</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">cursor</span><span class="p">,</span> <span class="n">keys</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">geoadd</span><span class="p">(</span><span class="s2">"geokey"</span><span class="p">,</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="s2">"value"</span><span class="p">))</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">zadd</span><span class="p">(</span><span class="s2">"zkey"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"value"</span><span class="p">:</span> <span class="mi">1000</span><span class="p">})</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">type</span><span class="p">(</span><span class="s2">"geokey"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; zset</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">type</span><span class="p">(</span><span class="s2">"zkey"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; zset</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">cursor</span><span class="p">,</span> <span class="n">keys</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">scan</span><span class="p">(</span><span class="n">cursor</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">_type</span><span class="o">=</span><span class="s2">"zset"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">keys</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; ['zkey', 'geokey']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">hset</span><span class="p">(</span><span class="s2">"myhash"</span><span class="p">,</span> <span class="n">mapping</span><span class="o">=</span><span class="p">{</span><span class="s2">"a"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"b"</span><span class="p">:</span> <span class="mi">2</span><span class="p">})</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">cursor</span><span class="p">,</span> <span class="n">keys</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">hscan</span><span class="p">(</span><span class="s2">"myhash"</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">keys</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; {'a': '1', 'b': '2'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">cursor</span><span class="p">,</span> <span class="n">keys</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">hscan</span><span class="p">(</span><span class="s2">"myhash"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">no_values</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">keys</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; ['a', 'b']</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_cmds_generic-stepscan1')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_cmds_generic-stepscan1" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/cmds_generic.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_cmds_generic-stepscan1" name="cmds_generic-stepscan1" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_cmds_generic-stepscan1" title="Open example"> Node.js </label> <div aria-labelledby="tab-cmds_generic-stepscan1" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_cmds_generic-stepscan1" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">createClient</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">().</span><span class="k">catch</span><span class="p">(</span><span class="nx">console</span><span class="p">.</span><span class="nx">error</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">delRes1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">'key1'</span><span class="p">,</span> <span class="s1">'Hello'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">delRes1</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">delRes2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">'key2'</span><span class="p">,</span> <span class="s1">'World'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">delRes2</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">delRes3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">([</span><span class="s1">'key1'</span><span class="p">,</span> <span class="s1">'key2'</span><span class="p">,</span> <span class="s1">'key3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">delRes3</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">expireRes1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">,</span> <span class="s1">'Hello'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">expireRes1</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">expireRes2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">expire</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">,</span> <span class="mi">10</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">expireRes2</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">expireRes3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ttl</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">expireRes3</span><span class="p">);</span> <span class="c1">// 10 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">expireRes4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">,</span> <span class="s1">'Hello World'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">expireRes4</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">expireRes5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ttl</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">expireRes5</span><span class="p">);</span> <span class="c1">// -1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">expireRes6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">expire</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="s2">"XX"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">expireRes6</span><span class="p">);</span> <span class="c1">// false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">expireRes7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ttl</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">expireRes7</span><span class="p">);</span> <span class="c1">// -1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">expireRes8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">expire</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="s2">"NX"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">expireRes8</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">expireRes9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ttl</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">expireRes9</span><span class="p">);</span> <span class="c1">// 10 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">ttlRes1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">,</span> <span class="s1">'Hello'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">ttlRes1</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">ttlRes2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">expire</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">,</span> <span class="mi">10</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">ttlRes2</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">ttlRes3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ttl</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">ttlRes3</span><span class="p">);</span> <span class="c1">// 10 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">scan1Res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'myset'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'1'</span><span class="p">,</span> <span class="s1">'2'</span><span class="p">,</span> <span class="s1">'3'</span><span class="p">,</span> <span class="s1">'foo'</span><span class="p">,</span> <span class="s1">'foobar'</span><span class="p">,</span> <span class="s1">'feelsgood'</span><span class="p">]);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scan1Res1</span><span class="p">);</span> <span class="c1">// 6 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">scan1Res2</span> <span class="o">=</span> <span class="p">[];</span> </span></span><span class="line hl"><span class="cl"><span class="k">for</span> <span class="kr">await</span> <span class="p">(</span><span class="kr">const</span> <span class="nx">value</span> <span class="k">of</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sScanIterator</span><span class="p">(</span><span class="s1">'myset'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">MATCH</span><span class="o">:</span> <span class="s1">'f*'</span> <span class="p">}))</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">scan1Res2</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">value</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="p">}</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scan1Res2</span><span class="p">);</span> <span class="c1">// ['foo', 'foobar', 'feelsgood'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kd">let</span> <span class="nx">cursor</span> <span class="o">=</span> <span class="s1">'0'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kd">let</span> <span class="nx">scanResult</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="nx">scanResult</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">scan</span><span class="p">(</span><span class="nx">cursor</span><span class="p">,</span> <span class="p">{</span> <span class="nx">MATCH</span><span class="o">:</span> <span class="s1">'*11*'</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scanResult</span><span class="p">.</span><span class="nx">cursor</span><span class="p">,</span> <span class="nx">scanResult</span><span class="p">.</span><span class="nx">keys</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="nx">scanResult</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">scan</span><span class="p">(</span><span class="nx">scanResult</span><span class="p">.</span><span class="nx">cursor</span><span class="p">,</span> <span class="p">{</span> <span class="nx">MATCH</span><span class="o">:</span> <span class="s1">'*11*'</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scanResult</span><span class="p">.</span><span class="nx">cursor</span><span class="p">,</span> <span class="nx">scanResult</span><span class="p">.</span><span class="nx">keys</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="nx">scanResult</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">scan</span><span class="p">(</span><span class="nx">scanResult</span><span class="p">.</span><span class="nx">cursor</span><span class="p">,</span> <span class="p">{</span> <span class="nx">MATCH</span><span class="o">:</span> <span class="s1">'*11*'</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scanResult</span><span class="p">.</span><span class="nx">cursor</span><span class="p">,</span> <span class="nx">scanResult</span><span class="p">.</span><span class="nx">keys</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="nx">scanResult</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">scan</span><span class="p">(</span><span class="nx">scanResult</span><span class="p">.</span><span class="nx">cursor</span><span class="p">,</span> <span class="p">{</span> <span class="nx">MATCH</span><span class="o">:</span> <span class="s1">'*11*'</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scanResult</span><span class="p">.</span><span class="nx">cursor</span><span class="p">,</span> <span class="nx">scanResult</span><span class="p">.</span><span class="nx">keys</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="nx">scanResult</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">scan</span><span class="p">(</span><span class="nx">scanResult</span><span class="p">.</span><span class="nx">cursor</span><span class="p">,</span> <span class="p">{</span> <span class="nx">MATCH</span><span class="o">:</span> <span class="s1">'*11*'</span><span class="p">,</span> <span class="nx">COUNT</span><span class="o">:</span> <span class="mi">1000</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scanResult</span><span class="p">.</span><span class="nx">cursor</span><span class="p">,</span> <span class="nx">scanResult</span><span class="p">.</span><span class="nx">keys</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">scan3Res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">geoAdd</span><span class="p">(</span><span class="s1">'geokey'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">longitude</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">latitude</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">member</span><span class="o">:</span> <span class="s1">'value'</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scan3Res1</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">scan3Res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zAdd</span><span class="p">(</span><span class="s1">'zkey'</span><span class="p">,</span> <span class="p">[{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">1000</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'value'</span> <span class="p">}]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scan3Res2</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">scan3Res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">type</span><span class="p">(</span><span class="s1">'geokey'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scan3Res3</span><span class="p">);</span> <span class="c1">// zset </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">scan3Res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">type</span><span class="p">(</span><span class="s1">'zkey'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scan3Res4</span><span class="p">);</span> <span class="c1">// zset </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">scan3Res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">scan</span><span class="p">(</span><span class="s1">'0'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">TYPE</span><span class="o">:</span> <span class="s1">'zset'</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scan3Res5</span><span class="p">.</span><span class="nx">keys</span><span class="p">);</span> <span class="c1">// ['zkey', 'geokey'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">scan4Res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">hSet</span><span class="p">(</span><span class="s1">'myhash'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">a</span><span class="o">:</span> <span class="mi">1</span><span class="p">,</span> <span class="nx">b</span><span class="o">:</span> <span class="mi">2</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scan4Res1</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">scan4Res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">hScan</span><span class="p">(</span><span class="s1">'myhash'</span><span class="p">,</span> <span class="mi">0</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scan4Res2</span><span class="p">.</span><span class="nx">tuples</span><span class="p">);</span> <span class="c1">// [{field: 'a', value: '1'}, {field: 'b', value: '2'}] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">scan4Res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">hScan</span><span class="p">(</span><span class="s1">'myhash'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="p">{</span> <span class="nx">COUNT</span><span class="o">:</span> <span class="mi">10</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">items</span> <span class="o">=</span> <span class="nx">scan4Res3</span><span class="p">.</span><span class="nx">tuples</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">item</span><span class="p">)</span> <span class="p">=&gt;</span> <span class="nx">item</span><span class="p">.</span><span class="nx">field</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">items</span><span class="p">);</span> <span class="c1">// ['a', 'b'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">quit</span><span class="p">();</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_cmds_generic-stepscan1')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_cmds_generic-stepscan1" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/cmds-generic.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_cmds_generic-stepscan1" name="cmds_generic-stepscan1" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_cmds_generic-stepscan1" title="Open example"> Java </label> <div aria-labelledby="tab-cmds_generic-stepscan1" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_cmds_generic-stepscan1" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.args.ExpiryOption</span><span class="o">;</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">CmdsGenericExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">delResult1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"key1"</span><span class="o">,</span> <span class="s">"Hello"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">delResult1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">delResult2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"key2"</span><span class="o">,</span> <span class="s">"World"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">delResult2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">delResult3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">del</span><span class="o">(</span><span class="s">"key1"</span><span class="o">,</span> <span class="s">"key2"</span><span class="o">,</span> <span class="s">"key3"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">delResult3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="c1">// Tests for 'del' step. </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">expireResult1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">,</span> <span class="s">"Hello"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">expireResult1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">expireResult2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">expire</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">,</span> <span class="mi">10</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">expireResult2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">expireResult3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ttl</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">expireResult3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 10 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">expireResult4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">,</span> <span class="s">"Hello World"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">expireResult4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">expireResult5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ttl</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">expireResult5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; -1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">expireResult6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">expire</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">,</span> <span class="mi">10</span><span class="o">,</span> <span class="n">ExpiryOption</span><span class="o">.</span><span class="na">XX</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">expireResult6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">expireResult7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ttl</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">expireResult7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; -1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">expireResult8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">expire</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">,</span> <span class="mi">10</span><span class="o">,</span> <span class="n">ExpiryOption</span><span class="o">.</span><span class="na">NX</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">expireResult8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">expireResult9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ttl</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">expireResult9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 10 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="c1">// Tests for 'expire' step. </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">ttlResult1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">,</span> <span class="s">"Hello"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">ttlResult1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">ttlResult2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">expire</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">,</span> <span class="mi">10</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">ttlResult2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">ttlResult3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ttl</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">ttlResult3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 10 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="c1">// Tests for 'ttl' step. </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_cmds_generic-stepscan1')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_cmds_generic-stepscan1" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/CmdsGenericExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_cmds_generic-stepscan1" name="cmds_generic-stepscan1" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_cmds_generic-stepscan1" title="Open example"> Go </label> <div aria-labelledby="tab-cmds_generic-stepscan1" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_cmds_generic-stepscan1" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> <span class="s">"math"</span> </span></span><span class="line"><span class="cl"> <span class="s">"time"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_del_cmd</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">delResult1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"key1"</span><span class="p">,</span> <span class="s">"Hello"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">delResult1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">delResult2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"key2"</span><span class="p">,</span> <span class="s">"World"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">delResult2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">delResult3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Del</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"key1"</span><span class="p">,</span> <span class="s">"key2"</span><span class="p">,</span> <span class="s">"key3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">delResult3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_expire_cmd</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">expireResult1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">,</span> <span class="s">"Hello"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">expireResult1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">expireResult2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Expire</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">,</span> <span class="mi">10</span><span class="o">*</span><span class="nx">time</span><span class="p">.</span><span class="nx">Second</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">expireResult2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">expireResult3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TTL</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nf">Round</span><span class="p">(</span><span class="nx">expireResult3</span><span class="p">.</span><span class="nf">Seconds</span><span class="p">()))</span> <span class="c1">// &gt;&gt;&gt; 10 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">expireResult4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">,</span> <span class="s">"Hello World"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">expireResult4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">expireResult5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TTL</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">expireResult5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; -1ns </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">expireResult6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">ExpireXX</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">,</span> <span class="mi">10</span><span class="o">*</span><span class="nx">time</span><span class="p">.</span><span class="nx">Second</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">expireResult6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">expireResult7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TTL</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">expireResult7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; -1ns </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">expireResult8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">ExpireNX</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">,</span> <span class="mi">10</span><span class="o">*</span><span class="nx">time</span><span class="p">.</span><span class="nx">Second</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">expireResult8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">expireResult9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TTL</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nf">Round</span><span class="p">(</span><span class="nx">expireResult9</span><span class="p">.</span><span class="nf">Seconds</span><span class="p">()))</span> <span class="c1">// &gt;&gt;&gt; 10 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ttl_cmd</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">ttlResult1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">,</span> <span class="s">"Hello"</span><span class="p">,</span> <span class="mi">10</span><span class="o">*</span><span class="nx">time</span><span class="p">.</span><span class="nx">Second</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">ttlResult1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">ttlResult2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TTL</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nf">Round</span><span class="p">(</span><span class="nx">ttlResult2</span><span class="p">.</span><span class="nf">Seconds</span><span class="p">()))</span> <span class="c1">// &gt;&gt;&gt; 10 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_cmds_generic-stepscan1')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_cmds_generic-stepscan1" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/cmds_generic_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_cmds_generic-stepscan1" name="cmds_generic-stepscan1" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_cmds_generic-stepscan1" title="Open example"> C# </label> <div aria-labelledby="tab-cmds_generic-stepscan1" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_cmds_generic-stepscan1" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Tests</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">StackExchange.Redis</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">CmdsGenericExample</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'copy' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">delResult1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"key1"</span><span class="p">,</span> <span class="s">"Hello"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">delResult1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">delResult2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"key2"</span><span class="p">,</span> <span class="s">"World"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">delResult2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">delResult3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyDelete</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"key1"</span><span class="p">,</span> <span class="s">"key2"</span><span class="p">,</span> <span class="s">"key3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">delResult3</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'del' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'dump' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'exists' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">expireResult1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">,</span> <span class="s">"Hello"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">expireResult1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">expireResult2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExpire</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">,</span> <span class="k">new</span> <span class="n">TimeSpan</span><span class="p">(</span><span class="m">0</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">10</span><span class="p">));</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">expireResult2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">TimeSpan</span> <span class="n">expireResult3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyTimeToLive</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">)</span> <span class="p">??</span> <span class="n">TimeSpan</span><span class="p">.</span><span class="n">Zero</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">Math</span><span class="p">.</span><span class="n">Round</span><span class="p">(</span><span class="n">expireResult3</span><span class="p">.</span><span class="n">TotalSeconds</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 10</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">expireResult4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">,</span> <span class="s">"Hello World"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">expireResult4</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">TimeSpan</span> <span class="n">expireResult5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyTimeToLive</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">)</span> <span class="p">??</span> <span class="n">TimeSpan</span><span class="p">.</span><span class="n">Zero</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">Math</span><span class="p">.</span><span class="n">Round</span><span class="p">(</span><span class="n">expireResult5</span><span class="p">.</span><span class="n">TotalSeconds</span><span class="p">).</span><span class="n">ToString</span><span class="p">());</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">expireResult6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExpire</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">,</span> <span class="k">new</span> <span class="n">TimeSpan</span><span class="p">(</span><span class="m">0</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">10</span><span class="p">),</span> <span class="n">ExpireWhen</span><span class="p">.</span><span class="n">HasExpiry</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">expireResult6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; false</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">TimeSpan</span> <span class="n">expireResult7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyTimeToLive</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">)</span> <span class="p">??</span> <span class="n">TimeSpan</span><span class="p">.</span><span class="n">Zero</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">Math</span><span class="p">.</span><span class="n">Round</span><span class="p">(</span><span class="n">expireResult7</span><span class="p">.</span><span class="n">TotalSeconds</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">expireResult8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExpire</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">,</span> <span class="k">new</span> <span class="n">TimeSpan</span><span class="p">(</span><span class="m">0</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">10</span><span class="p">),</span> <span class="n">ExpireWhen</span><span class="p">.</span><span class="n">HasNoExpiry</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">expireResult8</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">TimeSpan</span> <span class="n">expireResult9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyTimeToLive</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">)</span> <span class="p">??</span> <span class="n">TimeSpan</span><span class="p">.</span><span class="n">Zero</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">Math</span><span class="p">.</span><span class="n">Round</span><span class="p">(</span><span class="n">expireResult9</span><span class="p">.</span><span class="n">TotalSeconds</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 10</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'expire' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'expireat' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'expiretime' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'keys' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'migrate' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'move' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'object_encoding' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'object_freq' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'object_idletime' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'object_refcount' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'persist' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'pexpire' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'pexpireat' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'pexpiretime' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'pttl' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'randomkey' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'rename' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'renamenx' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'restore' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'scan1' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'scan2' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'scan3' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'scan4' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sort' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sort_ro' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'touch' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">ttlResult1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">,</span> <span class="s">"Hello"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">ttlResult1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">ttlResult2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExpire</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">,</span> <span class="k">new</span> <span class="n">TimeSpan</span><span class="p">(</span><span class="m">0</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">10</span><span class="p">));</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">ttlResult2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">TimeSpan</span> <span class="n">ttlResult3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyTimeToLive</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">)</span> <span class="p">??</span> <span class="n">TimeSpan</span><span class="p">.</span><span class="n">Zero</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> <span class="kt">string</span> <span class="n">ttlRes</span> <span class="p">=</span> <span class="n">Math</span><span class="p">.</span><span class="n">Round</span><span class="p">(</span><span class="n">ttlResult3</span><span class="p">.</span><span class="n">TotalSeconds</span><span class="p">).</span><span class="n">ToString</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">Math</span><span class="p">.</span><span class="n">Round</span><span class="p">(</span><span class="n">ttlResult3</span><span class="p">.</span><span class="n">TotalSeconds</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 10</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'ttl' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'type' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'unlink' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'wait' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'waitaof' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_cmds_generic-stepscan1')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_cmds_generic-stepscan1" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/CmdsGenericExample.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <p> It is important to note that the <strong> MATCH </strong> filter is applied after elements are retrieved from the collection, just before returning data to the client. This means that if the pattern matches very little elements inside the collection, <code> SCAN </code> will likely return no elements in most iterations. An example is shown below: </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="cmds_generic-stepscan2"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_cmds_generic-stepscan2" name="cmds_generic-stepscan2" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_cmds_generic-stepscan2" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-cmds_generic-stepscan2" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_cmds_generic-stepscan2" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; scan 0 MATCH *11* </span></span><span class="line hl"><span class="cl">1) "288" </span></span><span class="line hl"><span class="cl">2) 1) "key:911" </span></span><span class="line hl"><span class="cl">&gt; scan 288 MATCH *11* </span></span><span class="line hl"><span class="cl">1) "224" </span></span><span class="line hl"><span class="cl">2) (empty list or set) </span></span><span class="line hl"><span class="cl">&gt; scan 224 MATCH *11* </span></span><span class="line hl"><span class="cl">1) "80" </span></span><span class="line hl"><span class="cl">2) (empty list or set) </span></span><span class="line hl"><span class="cl">&gt; scan 80 MATCH *11* </span></span><span class="line hl"><span class="cl">1) "176" </span></span><span class="line hl"><span class="cl">2) (empty list or set) </span></span><span class="line hl"><span class="cl">&gt; scan 176 MATCH *11* COUNT 1000 </span></span><span class="line hl"><span class="cl">1) "0" </span></span><span class="line hl"><span class="cl">2) 1) "key:611" </span></span><span class="line hl"><span class="cl"> 2) "key:711" </span></span><span class="line hl"><span class="cl"> 3) "key:118" </span></span><span class="line hl"><span class="cl"> 4) "key:117" </span></span><span class="line hl"><span class="cl"> 5) "key:311" </span></span><span class="line hl"><span class="cl"> 6) "key:112" </span></span><span class="line hl"><span class="cl"> 7) "key:111" </span></span><span class="line hl"><span class="cl"> 8) "key:110" </span></span><span class="line hl"><span class="cl"> 9) "key:113" </span></span><span class="line hl"><span class="cl"> 10) "key:211" </span></span><span class="line hl"><span class="cl"> 11) "key:411" </span></span><span class="line hl"><span class="cl"> 12) "key:115" </span></span><span class="line hl"><span class="cl"> 13) "key:116" </span></span><span class="line hl"><span class="cl"> 14) "key:114" </span></span><span class="line hl"><span class="cl"> 15) "key:119" </span></span><span class="line hl"><span class="cl"> 16) "key:811" </span></span><span class="line hl"><span class="cl"> 17) "key:511" </span></span><span class="line hl"><span class="cl"> 18) "key:11"</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_cmds_generic-stepscan2')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_cmds_generic-stepscan2" name="cmds_generic-stepscan2" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_cmds_generic-stepscan2" title="Open example"> Python </label> <div aria-labelledby="tab-cmds_generic-stepscan2" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_cmds_generic-stepscan2" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"key1"</span><span class="p">,</span> <span class="s2">"Hello"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"key2"</span><span class="p">,</span> <span class="s2">"World"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"key1"</span><span class="p">,</span> <span class="s2">"key2"</span><span class="p">,</span> <span class="s2">"key3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">,</span> <span class="s2">"Hello"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">expire</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ttl</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; 10</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">,</span> <span class="s2">"Hello World"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ttl</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; -1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">expire</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="n">xx</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ttl</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; -1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">expire</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="n">nx</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ttl</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; 10</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">,</span> <span class="s2">"Hello"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">expire</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ttl</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; 10</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"myset"</span><span class="p">,</span> <span class="o">*</span><span class="nb">set</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="s2">"foo"</span><span class="p">,</span> <span class="s2">"foobar"</span><span class="p">,</span> <span class="s2">"feelsgood"</span><span class="p">]))</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; 6</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">r</span><span class="o">.</span><span class="n">sscan_iter</span><span class="p">(</span><span class="s2">"myset"</span><span class="p">,</span> <span class="n">match</span><span class="o">=</span><span class="s2">"f*"</span><span class="p">))</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; ['foobar', 'foo', 'feelsgood']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">cursor</span><span class="p">,</span> <span class="n">key</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">scan</span><span class="p">(</span><span class="n">cursor</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">match</span><span class="o">=</span><span class="s1">'*11*'</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">cursor</span><span class="p">,</span> <span class="n">key</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">cursor</span><span class="p">,</span> <span class="n">key</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">scan</span><span class="p">(</span><span class="n">cursor</span><span class="p">,</span> <span class="n">match</span><span class="o">=</span><span class="s1">'*11*'</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">cursor</span><span class="p">,</span> <span class="n">key</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">cursor</span><span class="p">,</span> <span class="n">key</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">scan</span><span class="p">(</span><span class="n">cursor</span><span class="p">,</span> <span class="n">match</span><span class="o">=</span><span class="s1">'*11*'</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">cursor</span><span class="p">,</span> <span class="n">key</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">cursor</span><span class="p">,</span> <span class="n">key</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">scan</span><span class="p">(</span><span class="n">cursor</span><span class="p">,</span> <span class="n">match</span><span class="o">=</span><span class="s1">'*11*'</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">cursor</span><span class="p">,</span> <span class="n">key</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">cursor</span><span class="p">,</span> <span class="n">keys</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">scan</span><span class="p">(</span><span class="n">cursor</span><span class="p">,</span> <span class="n">match</span><span class="o">=</span><span class="s1">'*11*'</span><span class="p">,</span> <span class="n">count</span><span class="o">=</span><span class="mi">1000</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">cursor</span><span class="p">,</span> <span class="n">keys</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">geoadd</span><span class="p">(</span><span class="s2">"geokey"</span><span class="p">,</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="s2">"value"</span><span class="p">))</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">zadd</span><span class="p">(</span><span class="s2">"zkey"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"value"</span><span class="p">:</span> <span class="mi">1000</span><span class="p">})</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">type</span><span class="p">(</span><span class="s2">"geokey"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; zset</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">type</span><span class="p">(</span><span class="s2">"zkey"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; zset</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">cursor</span><span class="p">,</span> <span class="n">keys</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">scan</span><span class="p">(</span><span class="n">cursor</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">_type</span><span class="o">=</span><span class="s2">"zset"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">keys</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; ['zkey', 'geokey']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">hset</span><span class="p">(</span><span class="s2">"myhash"</span><span class="p">,</span> <span class="n">mapping</span><span class="o">=</span><span class="p">{</span><span class="s2">"a"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"b"</span><span class="p">:</span> <span class="mi">2</span><span class="p">})</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">cursor</span><span class="p">,</span> <span class="n">keys</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">hscan</span><span class="p">(</span><span class="s2">"myhash"</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">keys</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; {'a': '1', 'b': '2'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">cursor</span><span class="p">,</span> <span class="n">keys</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">hscan</span><span class="p">(</span><span class="s2">"myhash"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">no_values</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">keys</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; ['a', 'b']</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_cmds_generic-stepscan2')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_cmds_generic-stepscan2" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/cmds_generic.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_cmds_generic-stepscan2" name="cmds_generic-stepscan2" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_cmds_generic-stepscan2" title="Open example"> Node.js </label> <div aria-labelledby="tab-cmds_generic-stepscan2" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_cmds_generic-stepscan2" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">createClient</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">().</span><span class="k">catch</span><span class="p">(</span><span class="nx">console</span><span class="p">.</span><span class="nx">error</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">delRes1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">'key1'</span><span class="p">,</span> <span class="s1">'Hello'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">delRes1</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">delRes2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">'key2'</span><span class="p">,</span> <span class="s1">'World'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">delRes2</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">delRes3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">([</span><span class="s1">'key1'</span><span class="p">,</span> <span class="s1">'key2'</span><span class="p">,</span> <span class="s1">'key3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">delRes3</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">expireRes1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">,</span> <span class="s1">'Hello'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">expireRes1</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">expireRes2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">expire</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">,</span> <span class="mi">10</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">expireRes2</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">expireRes3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ttl</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">expireRes3</span><span class="p">);</span> <span class="c1">// 10 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">expireRes4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">,</span> <span class="s1">'Hello World'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">expireRes4</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">expireRes5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ttl</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">expireRes5</span><span class="p">);</span> <span class="c1">// -1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">expireRes6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">expire</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="s2">"XX"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">expireRes6</span><span class="p">);</span> <span class="c1">// false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">expireRes7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ttl</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">expireRes7</span><span class="p">);</span> <span class="c1">// -1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">expireRes8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">expire</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="s2">"NX"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">expireRes8</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">expireRes9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ttl</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">expireRes9</span><span class="p">);</span> <span class="c1">// 10 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">ttlRes1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">,</span> <span class="s1">'Hello'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">ttlRes1</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">ttlRes2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">expire</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">,</span> <span class="mi">10</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">ttlRes2</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">ttlRes3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ttl</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">ttlRes3</span><span class="p">);</span> <span class="c1">// 10 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">scan1Res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'myset'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'1'</span><span class="p">,</span> <span class="s1">'2'</span><span class="p">,</span> <span class="s1">'3'</span><span class="p">,</span> <span class="s1">'foo'</span><span class="p">,</span> <span class="s1">'foobar'</span><span class="p">,</span> <span class="s1">'feelsgood'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scan1Res1</span><span class="p">);</span> <span class="c1">// 6 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">scan1Res2</span> <span class="o">=</span> <span class="p">[];</span> </span></span><span class="line"><span class="cl"><span class="k">for</span> <span class="kr">await</span> <span class="p">(</span><span class="kr">const</span> <span class="nx">value</span> <span class="k">of</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sScanIterator</span><span class="p">(</span><span class="s1">'myset'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">MATCH</span><span class="o">:</span> <span class="s1">'f*'</span> <span class="p">}))</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">scan1Res2</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">value</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scan1Res2</span><span class="p">);</span> <span class="c1">// ['foo', 'foobar', 'feelsgood'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kd">let</span> <span class="nx">cursor</span> <span class="o">=</span> <span class="s1">'0'</span><span class="p">;</span> </span></span><span class="line hl"><span class="cl"><span class="kd">let</span> <span class="nx">scanResult</span><span class="p">;</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="nx">scanResult</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">scan</span><span class="p">(</span><span class="nx">cursor</span><span class="p">,</span> <span class="p">{</span> <span class="nx">MATCH</span><span class="o">:</span> <span class="s1">'*11*'</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scanResult</span><span class="p">.</span><span class="nx">cursor</span><span class="p">,</span> <span class="nx">scanResult</span><span class="p">.</span><span class="nx">keys</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="nx">scanResult</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">scan</span><span class="p">(</span><span class="nx">scanResult</span><span class="p">.</span><span class="nx">cursor</span><span class="p">,</span> <span class="p">{</span> <span class="nx">MATCH</span><span class="o">:</span> <span class="s1">'*11*'</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scanResult</span><span class="p">.</span><span class="nx">cursor</span><span class="p">,</span> <span class="nx">scanResult</span><span class="p">.</span><span class="nx">keys</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="nx">scanResult</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">scan</span><span class="p">(</span><span class="nx">scanResult</span><span class="p">.</span><span class="nx">cursor</span><span class="p">,</span> <span class="p">{</span> <span class="nx">MATCH</span><span class="o">:</span> <span class="s1">'*11*'</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scanResult</span><span class="p">.</span><span class="nx">cursor</span><span class="p">,</span> <span class="nx">scanResult</span><span class="p">.</span><span class="nx">keys</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="nx">scanResult</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">scan</span><span class="p">(</span><span class="nx">scanResult</span><span class="p">.</span><span class="nx">cursor</span><span class="p">,</span> <span class="p">{</span> <span class="nx">MATCH</span><span class="o">:</span> <span class="s1">'*11*'</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scanResult</span><span class="p">.</span><span class="nx">cursor</span><span class="p">,</span> <span class="nx">scanResult</span><span class="p">.</span><span class="nx">keys</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="nx">scanResult</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">scan</span><span class="p">(</span><span class="nx">scanResult</span><span class="p">.</span><span class="nx">cursor</span><span class="p">,</span> <span class="p">{</span> <span class="nx">MATCH</span><span class="o">:</span> <span class="s1">'*11*'</span><span class="p">,</span> <span class="nx">COUNT</span><span class="o">:</span> <span class="mi">1000</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scanResult</span><span class="p">.</span><span class="nx">cursor</span><span class="p">,</span> <span class="nx">scanResult</span><span class="p">.</span><span class="nx">keys</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">scan3Res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">geoAdd</span><span class="p">(</span><span class="s1">'geokey'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">longitude</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">latitude</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">member</span><span class="o">:</span> <span class="s1">'value'</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scan3Res1</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">scan3Res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zAdd</span><span class="p">(</span><span class="s1">'zkey'</span><span class="p">,</span> <span class="p">[{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">1000</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'value'</span> <span class="p">}]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scan3Res2</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">scan3Res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">type</span><span class="p">(</span><span class="s1">'geokey'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scan3Res3</span><span class="p">);</span> <span class="c1">// zset </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">scan3Res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">type</span><span class="p">(</span><span class="s1">'zkey'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scan3Res4</span><span class="p">);</span> <span class="c1">// zset </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">scan3Res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">scan</span><span class="p">(</span><span class="s1">'0'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">TYPE</span><span class="o">:</span> <span class="s1">'zset'</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scan3Res5</span><span class="p">.</span><span class="nx">keys</span><span class="p">);</span> <span class="c1">// ['zkey', 'geokey'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">scan4Res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">hSet</span><span class="p">(</span><span class="s1">'myhash'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">a</span><span class="o">:</span> <span class="mi">1</span><span class="p">,</span> <span class="nx">b</span><span class="o">:</span> <span class="mi">2</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scan4Res1</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">scan4Res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">hScan</span><span class="p">(</span><span class="s1">'myhash'</span><span class="p">,</span> <span class="mi">0</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scan4Res2</span><span class="p">.</span><span class="nx">tuples</span><span class="p">);</span> <span class="c1">// [{field: 'a', value: '1'}, {field: 'b', value: '2'}] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">scan4Res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">hScan</span><span class="p">(</span><span class="s1">'myhash'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="p">{</span> <span class="nx">COUNT</span><span class="o">:</span> <span class="mi">10</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">items</span> <span class="o">=</span> <span class="nx">scan4Res3</span><span class="p">.</span><span class="nx">tuples</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">item</span><span class="p">)</span> <span class="p">=&gt;</span> <span class="nx">item</span><span class="p">.</span><span class="nx">field</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">items</span><span class="p">);</span> <span class="c1">// ['a', 'b'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">quit</span><span class="p">();</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_cmds_generic-stepscan2')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_cmds_generic-stepscan2" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/cmds-generic.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_cmds_generic-stepscan2" name="cmds_generic-stepscan2" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_cmds_generic-stepscan2" title="Open example"> Java </label> <div aria-labelledby="tab-cmds_generic-stepscan2" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_cmds_generic-stepscan2" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.args.ExpiryOption</span><span class="o">;</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">CmdsGenericExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">delResult1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"key1"</span><span class="o">,</span> <span class="s">"Hello"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">delResult1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">delResult2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"key2"</span><span class="o">,</span> <span class="s">"World"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">delResult2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">delResult3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">del</span><span class="o">(</span><span class="s">"key1"</span><span class="o">,</span> <span class="s">"key2"</span><span class="o">,</span> <span class="s">"key3"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">delResult3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="c1">// Tests for 'del' step. </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">expireResult1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">,</span> <span class="s">"Hello"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">expireResult1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">expireResult2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">expire</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">,</span> <span class="mi">10</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">expireResult2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">expireResult3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ttl</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">expireResult3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 10 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">expireResult4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">,</span> <span class="s">"Hello World"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">expireResult4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">expireResult5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ttl</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">expireResult5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; -1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">expireResult6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">expire</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">,</span> <span class="mi">10</span><span class="o">,</span> <span class="n">ExpiryOption</span><span class="o">.</span><span class="na">XX</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">expireResult6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">expireResult7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ttl</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">expireResult7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; -1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">expireResult8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">expire</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">,</span> <span class="mi">10</span><span class="o">,</span> <span class="n">ExpiryOption</span><span class="o">.</span><span class="na">NX</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">expireResult8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">expireResult9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ttl</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">expireResult9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 10 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="c1">// Tests for 'expire' step. </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">ttlResult1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">,</span> <span class="s">"Hello"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">ttlResult1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">ttlResult2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">expire</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">,</span> <span class="mi">10</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">ttlResult2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">ttlResult3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ttl</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">ttlResult3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 10 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="c1">// Tests for 'ttl' step. </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_cmds_generic-stepscan2')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_cmds_generic-stepscan2" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/CmdsGenericExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_cmds_generic-stepscan2" name="cmds_generic-stepscan2" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_cmds_generic-stepscan2" title="Open example"> Go </label> <div aria-labelledby="tab-cmds_generic-stepscan2" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_cmds_generic-stepscan2" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> <span class="s">"math"</span> </span></span><span class="line"><span class="cl"> <span class="s">"time"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_del_cmd</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">delResult1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"key1"</span><span class="p">,</span> <span class="s">"Hello"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">delResult1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">delResult2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"key2"</span><span class="p">,</span> <span class="s">"World"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">delResult2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">delResult3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Del</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"key1"</span><span class="p">,</span> <span class="s">"key2"</span><span class="p">,</span> <span class="s">"key3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">delResult3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_expire_cmd</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">expireResult1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">,</span> <span class="s">"Hello"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">expireResult1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">expireResult2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Expire</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">,</span> <span class="mi">10</span><span class="o">*</span><span class="nx">time</span><span class="p">.</span><span class="nx">Second</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">expireResult2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">expireResult3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TTL</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nf">Round</span><span class="p">(</span><span class="nx">expireResult3</span><span class="p">.</span><span class="nf">Seconds</span><span class="p">()))</span> <span class="c1">// &gt;&gt;&gt; 10 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">expireResult4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">,</span> <span class="s">"Hello World"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">expireResult4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">expireResult5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TTL</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">expireResult5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; -1ns </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">expireResult6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">ExpireXX</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">,</span> <span class="mi">10</span><span class="o">*</span><span class="nx">time</span><span class="p">.</span><span class="nx">Second</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">expireResult6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">expireResult7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TTL</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">expireResult7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; -1ns </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">expireResult8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">ExpireNX</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">,</span> <span class="mi">10</span><span class="o">*</span><span class="nx">time</span><span class="p">.</span><span class="nx">Second</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">expireResult8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">expireResult9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TTL</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nf">Round</span><span class="p">(</span><span class="nx">expireResult9</span><span class="p">.</span><span class="nf">Seconds</span><span class="p">()))</span> <span class="c1">// &gt;&gt;&gt; 10 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ttl_cmd</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">ttlResult1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">,</span> <span class="s">"Hello"</span><span class="p">,</span> <span class="mi">10</span><span class="o">*</span><span class="nx">time</span><span class="p">.</span><span class="nx">Second</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">ttlResult1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">ttlResult2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TTL</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nf">Round</span><span class="p">(</span><span class="nx">ttlResult2</span><span class="p">.</span><span class="nf">Seconds</span><span class="p">()))</span> <span class="c1">// &gt;&gt;&gt; 10 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_cmds_generic-stepscan2')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_cmds_generic-stepscan2" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/cmds_generic_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_cmds_generic-stepscan2" name="cmds_generic-stepscan2" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_cmds_generic-stepscan2" title="Open example"> C# </label> <div aria-labelledby="tab-cmds_generic-stepscan2" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_cmds_generic-stepscan2" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Tests</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">StackExchange.Redis</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">CmdsGenericExample</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'copy' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">delResult1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"key1"</span><span class="p">,</span> <span class="s">"Hello"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">delResult1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">delResult2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"key2"</span><span class="p">,</span> <span class="s">"World"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">delResult2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">delResult3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyDelete</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"key1"</span><span class="p">,</span> <span class="s">"key2"</span><span class="p">,</span> <span class="s">"key3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">delResult3</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'del' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'dump' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'exists' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">expireResult1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">,</span> <span class="s">"Hello"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">expireResult1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">expireResult2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExpire</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">,</span> <span class="k">new</span> <span class="n">TimeSpan</span><span class="p">(</span><span class="m">0</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">10</span><span class="p">));</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">expireResult2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">TimeSpan</span> <span class="n">expireResult3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyTimeToLive</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">)</span> <span class="p">??</span> <span class="n">TimeSpan</span><span class="p">.</span><span class="n">Zero</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">Math</span><span class="p">.</span><span class="n">Round</span><span class="p">(</span><span class="n">expireResult3</span><span class="p">.</span><span class="n">TotalSeconds</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 10</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">expireResult4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">,</span> <span class="s">"Hello World"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">expireResult4</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">TimeSpan</span> <span class="n">expireResult5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyTimeToLive</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">)</span> <span class="p">??</span> <span class="n">TimeSpan</span><span class="p">.</span><span class="n">Zero</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">Math</span><span class="p">.</span><span class="n">Round</span><span class="p">(</span><span class="n">expireResult5</span><span class="p">.</span><span class="n">TotalSeconds</span><span class="p">).</span><span class="n">ToString</span><span class="p">());</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">expireResult6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExpire</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">,</span> <span class="k">new</span> <span class="n">TimeSpan</span><span class="p">(</span><span class="m">0</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">10</span><span class="p">),</span> <span class="n">ExpireWhen</span><span class="p">.</span><span class="n">HasExpiry</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">expireResult6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; false</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">TimeSpan</span> <span class="n">expireResult7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyTimeToLive</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">)</span> <span class="p">??</span> <span class="n">TimeSpan</span><span class="p">.</span><span class="n">Zero</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">Math</span><span class="p">.</span><span class="n">Round</span><span class="p">(</span><span class="n">expireResult7</span><span class="p">.</span><span class="n">TotalSeconds</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">expireResult8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExpire</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">,</span> <span class="k">new</span> <span class="n">TimeSpan</span><span class="p">(</span><span class="m">0</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">10</span><span class="p">),</span> <span class="n">ExpireWhen</span><span class="p">.</span><span class="n">HasNoExpiry</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">expireResult8</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">TimeSpan</span> <span class="n">expireResult9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyTimeToLive</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">)</span> <span class="p">??</span> <span class="n">TimeSpan</span><span class="p">.</span><span class="n">Zero</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">Math</span><span class="p">.</span><span class="n">Round</span><span class="p">(</span><span class="n">expireResult9</span><span class="p">.</span><span class="n">TotalSeconds</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 10</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'expire' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'expireat' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'expiretime' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'keys' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'migrate' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'move' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'object_encoding' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'object_freq' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'object_idletime' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'object_refcount' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'persist' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'pexpire' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'pexpireat' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'pexpiretime' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'pttl' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'randomkey' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'rename' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'renamenx' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'restore' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'scan1' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'scan2' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'scan3' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'scan4' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sort' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sort_ro' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'touch' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">ttlResult1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">,</span> <span class="s">"Hello"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">ttlResult1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">ttlResult2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExpire</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">,</span> <span class="k">new</span> <span class="n">TimeSpan</span><span class="p">(</span><span class="m">0</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">10</span><span class="p">));</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">ttlResult2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">TimeSpan</span> <span class="n">ttlResult3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyTimeToLive</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">)</span> <span class="p">??</span> <span class="n">TimeSpan</span><span class="p">.</span><span class="n">Zero</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> <span class="kt">string</span> <span class="n">ttlRes</span> <span class="p">=</span> <span class="n">Math</span><span class="p">.</span><span class="n">Round</span><span class="p">(</span><span class="n">ttlResult3</span><span class="p">.</span><span class="n">TotalSeconds</span><span class="p">).</span><span class="n">ToString</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">Math</span><span class="p">.</span><span class="n">Round</span><span class="p">(</span><span class="n">ttlResult3</span><span class="p">.</span><span class="n">TotalSeconds</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 10</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'ttl' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'type' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'unlink' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'wait' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'waitaof' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_cmds_generic-stepscan2')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_cmds_generic-stepscan2" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/CmdsGenericExample.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <p> As you can see most of the calls returned zero elements, but the last call where a <code> COUNT </code> of 1000 was used in order to force the command to do more scanning for that iteration. </p> <p> When using <a href="/docs/latest/operate/oss_and_stack/management/scaling/"> Redis Cluster </a> , the search is optimized for patterns that imply a single slot. If a pattern can only match keys of one slot, Redis only iterates over keys in that slot, rather than the whole database, when searching for keys matching the pattern. For example, with the pattern <code> {a}h*llo </code> , Redis would only try to match it with the keys in slot 15495, which hash tag <code> {a} </code> implies. To use pattern with hash tag, see <a href="/docs/latest/operate/oss_and_stack/reference/cluster-spec#hash-tags"> Hash tags </a> in the Cluster specification for more information. </p> <h2 id="the-type-option"> The TYPE option </h2> <p> You can use the <code> TYPE </code> option to ask <code> SCAN </code> to only return objects that match a given <code> type </code> , allowing you to iterate through the database looking for keys of a specific type. The <strong> TYPE </strong> option is only available on the whole-database <code> SCAN </code> , not <a href="/docs/latest/commands/hscan/"> <code> HSCAN </code> </a> or <a href="/docs/latest/commands/zscan/"> <code> ZSCAN </code> </a> etc. </p> <p> The <code> type </code> argument is the same string name that the <a href="/docs/latest/commands/type/"> <code> TYPE </code> </a> command returns. Note a quirk where some Redis types, such as GeoHashes, HyperLogLogs, Bitmaps, and Bitfields, may internally be implemented using other Redis types, such as a string or zset, so can't be distinguished from other keys of that same type by <code> SCAN </code> . For example, a ZSET and GEOHASH: </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="cmds_generic-stepscan3"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_cmds_generic-stepscan3" name="cmds_generic-stepscan3" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_cmds_generic-stepscan3" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-cmds_generic-stepscan3" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_cmds_generic-stepscan3" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; GEOADD geokey 0 0 value </span></span><span class="line hl"><span class="cl">(integer) 1 </span></span><span class="line hl"><span class="cl">&gt; ZADD zkey 1000 value </span></span><span class="line hl"><span class="cl">(integer) 1 </span></span><span class="line hl"><span class="cl">&gt; TYPE geokey </span></span><span class="line hl"><span class="cl">zset </span></span><span class="line hl"><span class="cl">&gt; TYPE zkey </span></span><span class="line hl"><span class="cl">zset </span></span><span class="line hl"><span class="cl">&gt; SCAN 0 TYPE zset </span></span><span class="line hl"><span class="cl">1) "0" </span></span><span class="line hl"><span class="cl">2) 1) "geokey" </span></span><span class="line hl"><span class="cl"> 2) "zkey"</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_cmds_generic-stepscan3')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_cmds_generic-stepscan3" name="cmds_generic-stepscan3" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_cmds_generic-stepscan3" title="Open example"> Python </label> <div aria-labelledby="tab-cmds_generic-stepscan3" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_cmds_generic-stepscan3" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"key1"</span><span class="p">,</span> <span class="s2">"Hello"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"key2"</span><span class="p">,</span> <span class="s2">"World"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"key1"</span><span class="p">,</span> <span class="s2">"key2"</span><span class="p">,</span> <span class="s2">"key3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">,</span> <span class="s2">"Hello"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">expire</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ttl</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; 10</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">,</span> <span class="s2">"Hello World"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ttl</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; -1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">expire</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="n">xx</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ttl</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; -1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">expire</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="n">nx</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ttl</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; 10</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">,</span> <span class="s2">"Hello"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">expire</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ttl</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; 10</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"myset"</span><span class="p">,</span> <span class="o">*</span><span class="nb">set</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="s2">"foo"</span><span class="p">,</span> <span class="s2">"foobar"</span><span class="p">,</span> <span class="s2">"feelsgood"</span><span class="p">]))</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; 6</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">r</span><span class="o">.</span><span class="n">sscan_iter</span><span class="p">(</span><span class="s2">"myset"</span><span class="p">,</span> <span class="n">match</span><span class="o">=</span><span class="s2">"f*"</span><span class="p">))</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; ['foobar', 'foo', 'feelsgood']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">cursor</span><span class="p">,</span> <span class="n">key</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">scan</span><span class="p">(</span><span class="n">cursor</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">match</span><span class="o">=</span><span class="s1">'*11*'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">cursor</span><span class="p">,</span> <span class="n">key</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">cursor</span><span class="p">,</span> <span class="n">key</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">scan</span><span class="p">(</span><span class="n">cursor</span><span class="p">,</span> <span class="n">match</span><span class="o">=</span><span class="s1">'*11*'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">cursor</span><span class="p">,</span> <span class="n">key</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">cursor</span><span class="p">,</span> <span class="n">key</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">scan</span><span class="p">(</span><span class="n">cursor</span><span class="p">,</span> <span class="n">match</span><span class="o">=</span><span class="s1">'*11*'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">cursor</span><span class="p">,</span> <span class="n">key</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">cursor</span><span class="p">,</span> <span class="n">key</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">scan</span><span class="p">(</span><span class="n">cursor</span><span class="p">,</span> <span class="n">match</span><span class="o">=</span><span class="s1">'*11*'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">cursor</span><span class="p">,</span> <span class="n">key</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">cursor</span><span class="p">,</span> <span class="n">keys</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">scan</span><span class="p">(</span><span class="n">cursor</span><span class="p">,</span> <span class="n">match</span><span class="o">=</span><span class="s1">'*11*'</span><span class="p">,</span> <span class="n">count</span><span class="o">=</span><span class="mi">1000</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">cursor</span><span class="p">,</span> <span class="n">keys</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">geoadd</span><span class="p">(</span><span class="s2">"geokey"</span><span class="p">,</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="s2">"value"</span><span class="p">))</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">zadd</span><span class="p">(</span><span class="s2">"zkey"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"value"</span><span class="p">:</span> <span class="mi">1000</span><span class="p">})</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">type</span><span class="p">(</span><span class="s2">"geokey"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="c1"># &gt;&gt;&gt; zset</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">type</span><span class="p">(</span><span class="s2">"zkey"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="c1"># &gt;&gt;&gt; zset</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">cursor</span><span class="p">,</span> <span class="n">keys</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">scan</span><span class="p">(</span><span class="n">cursor</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">_type</span><span class="o">=</span><span class="s2">"zset"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">keys</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="c1"># &gt;&gt;&gt; ['zkey', 'geokey']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">hset</span><span class="p">(</span><span class="s2">"myhash"</span><span class="p">,</span> <span class="n">mapping</span><span class="o">=</span><span class="p">{</span><span class="s2">"a"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"b"</span><span class="p">:</span> <span class="mi">2</span><span class="p">})</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">cursor</span><span class="p">,</span> <span class="n">keys</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">hscan</span><span class="p">(</span><span class="s2">"myhash"</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">keys</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; {'a': '1', 'b': '2'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">cursor</span><span class="p">,</span> <span class="n">keys</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">hscan</span><span class="p">(</span><span class="s2">"myhash"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">no_values</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">keys</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; ['a', 'b']</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_cmds_generic-stepscan3')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_cmds_generic-stepscan3" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/cmds_generic.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_cmds_generic-stepscan3" name="cmds_generic-stepscan3" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_cmds_generic-stepscan3" title="Open example"> Node.js </label> <div aria-labelledby="tab-cmds_generic-stepscan3" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_cmds_generic-stepscan3" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">createClient</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">().</span><span class="k">catch</span><span class="p">(</span><span class="nx">console</span><span class="p">.</span><span class="nx">error</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">delRes1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">'key1'</span><span class="p">,</span> <span class="s1">'Hello'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">delRes1</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">delRes2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">'key2'</span><span class="p">,</span> <span class="s1">'World'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">delRes2</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">delRes3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">([</span><span class="s1">'key1'</span><span class="p">,</span> <span class="s1">'key2'</span><span class="p">,</span> <span class="s1">'key3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">delRes3</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">expireRes1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">,</span> <span class="s1">'Hello'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">expireRes1</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">expireRes2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">expire</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">,</span> <span class="mi">10</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">expireRes2</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">expireRes3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ttl</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">expireRes3</span><span class="p">);</span> <span class="c1">// 10 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">expireRes4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">,</span> <span class="s1">'Hello World'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">expireRes4</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">expireRes5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ttl</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">expireRes5</span><span class="p">);</span> <span class="c1">// -1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">expireRes6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">expire</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="s2">"XX"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">expireRes6</span><span class="p">);</span> <span class="c1">// false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">expireRes7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ttl</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">expireRes7</span><span class="p">);</span> <span class="c1">// -1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">expireRes8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">expire</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="s2">"NX"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">expireRes8</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">expireRes9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ttl</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">expireRes9</span><span class="p">);</span> <span class="c1">// 10 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">ttlRes1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">,</span> <span class="s1">'Hello'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">ttlRes1</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">ttlRes2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">expire</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">,</span> <span class="mi">10</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">ttlRes2</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">ttlRes3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ttl</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">ttlRes3</span><span class="p">);</span> <span class="c1">// 10 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">scan1Res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'myset'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'1'</span><span class="p">,</span> <span class="s1">'2'</span><span class="p">,</span> <span class="s1">'3'</span><span class="p">,</span> <span class="s1">'foo'</span><span class="p">,</span> <span class="s1">'foobar'</span><span class="p">,</span> <span class="s1">'feelsgood'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scan1Res1</span><span class="p">);</span> <span class="c1">// 6 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">scan1Res2</span> <span class="o">=</span> <span class="p">[];</span> </span></span><span class="line"><span class="cl"><span class="k">for</span> <span class="kr">await</span> <span class="p">(</span><span class="kr">const</span> <span class="nx">value</span> <span class="k">of</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sScanIterator</span><span class="p">(</span><span class="s1">'myset'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">MATCH</span><span class="o">:</span> <span class="s1">'f*'</span> <span class="p">}))</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">scan1Res2</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">value</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scan1Res2</span><span class="p">);</span> <span class="c1">// ['foo', 'foobar', 'feelsgood'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kd">let</span> <span class="nx">cursor</span> <span class="o">=</span> <span class="s1">'0'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kd">let</span> <span class="nx">scanResult</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="nx">scanResult</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">scan</span><span class="p">(</span><span class="nx">cursor</span><span class="p">,</span> <span class="p">{</span> <span class="nx">MATCH</span><span class="o">:</span> <span class="s1">'*11*'</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scanResult</span><span class="p">.</span><span class="nx">cursor</span><span class="p">,</span> <span class="nx">scanResult</span><span class="p">.</span><span class="nx">keys</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="nx">scanResult</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">scan</span><span class="p">(</span><span class="nx">scanResult</span><span class="p">.</span><span class="nx">cursor</span><span class="p">,</span> <span class="p">{</span> <span class="nx">MATCH</span><span class="o">:</span> <span class="s1">'*11*'</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scanResult</span><span class="p">.</span><span class="nx">cursor</span><span class="p">,</span> <span class="nx">scanResult</span><span class="p">.</span><span class="nx">keys</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="nx">scanResult</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">scan</span><span class="p">(</span><span class="nx">scanResult</span><span class="p">.</span><span class="nx">cursor</span><span class="p">,</span> <span class="p">{</span> <span class="nx">MATCH</span><span class="o">:</span> <span class="s1">'*11*'</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scanResult</span><span class="p">.</span><span class="nx">cursor</span><span class="p">,</span> <span class="nx">scanResult</span><span class="p">.</span><span class="nx">keys</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="nx">scanResult</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">scan</span><span class="p">(</span><span class="nx">scanResult</span><span class="p">.</span><span class="nx">cursor</span><span class="p">,</span> <span class="p">{</span> <span class="nx">MATCH</span><span class="o">:</span> <span class="s1">'*11*'</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scanResult</span><span class="p">.</span><span class="nx">cursor</span><span class="p">,</span> <span class="nx">scanResult</span><span class="p">.</span><span class="nx">keys</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="nx">scanResult</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">scan</span><span class="p">(</span><span class="nx">scanResult</span><span class="p">.</span><span class="nx">cursor</span><span class="p">,</span> <span class="p">{</span> <span class="nx">MATCH</span><span class="o">:</span> <span class="s1">'*11*'</span><span class="p">,</span> <span class="nx">COUNT</span><span class="o">:</span> <span class="mi">1000</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scanResult</span><span class="p">.</span><span class="nx">cursor</span><span class="p">,</span> <span class="nx">scanResult</span><span class="p">.</span><span class="nx">keys</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">scan3Res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">geoAdd</span><span class="p">(</span><span class="s1">'geokey'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">longitude</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">latitude</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">member</span><span class="o">:</span> <span class="s1">'value'</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scan3Res1</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">scan3Res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zAdd</span><span class="p">(</span><span class="s1">'zkey'</span><span class="p">,</span> <span class="p">[{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">1000</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'value'</span> <span class="p">}]);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scan3Res2</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">scan3Res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">type</span><span class="p">(</span><span class="s1">'geokey'</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scan3Res3</span><span class="p">);</span> <span class="c1">// zset </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">scan3Res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">type</span><span class="p">(</span><span class="s1">'zkey'</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scan3Res4</span><span class="p">);</span> <span class="c1">// zset </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">scan3Res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">scan</span><span class="p">(</span><span class="s1">'0'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">TYPE</span><span class="o">:</span> <span class="s1">'zset'</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scan3Res5</span><span class="p">.</span><span class="nx">keys</span><span class="p">);</span> <span class="c1">// ['zkey', 'geokey'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">scan4Res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">hSet</span><span class="p">(</span><span class="s1">'myhash'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">a</span><span class="o">:</span> <span class="mi">1</span><span class="p">,</span> <span class="nx">b</span><span class="o">:</span> <span class="mi">2</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scan4Res1</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">scan4Res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">hScan</span><span class="p">(</span><span class="s1">'myhash'</span><span class="p">,</span> <span class="mi">0</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scan4Res2</span><span class="p">.</span><span class="nx">tuples</span><span class="p">);</span> <span class="c1">// [{field: 'a', value: '1'}, {field: 'b', value: '2'}] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">scan4Res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">hScan</span><span class="p">(</span><span class="s1">'myhash'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="p">{</span> <span class="nx">COUNT</span><span class="o">:</span> <span class="mi">10</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">items</span> <span class="o">=</span> <span class="nx">scan4Res3</span><span class="p">.</span><span class="nx">tuples</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">item</span><span class="p">)</span> <span class="p">=&gt;</span> <span class="nx">item</span><span class="p">.</span><span class="nx">field</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">items</span><span class="p">);</span> <span class="c1">// ['a', 'b'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">quit</span><span class="p">();</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_cmds_generic-stepscan3')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_cmds_generic-stepscan3" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/cmds-generic.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_cmds_generic-stepscan3" name="cmds_generic-stepscan3" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_cmds_generic-stepscan3" title="Open example"> Java </label> <div aria-labelledby="tab-cmds_generic-stepscan3" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_cmds_generic-stepscan3" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.args.ExpiryOption</span><span class="o">;</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">CmdsGenericExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">delResult1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"key1"</span><span class="o">,</span> <span class="s">"Hello"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">delResult1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">delResult2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"key2"</span><span class="o">,</span> <span class="s">"World"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">delResult2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">delResult3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">del</span><span class="o">(</span><span class="s">"key1"</span><span class="o">,</span> <span class="s">"key2"</span><span class="o">,</span> <span class="s">"key3"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">delResult3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="c1">// Tests for 'del' step. </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">expireResult1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">,</span> <span class="s">"Hello"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">expireResult1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">expireResult2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">expire</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">,</span> <span class="mi">10</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">expireResult2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">expireResult3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ttl</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">expireResult3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 10 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">expireResult4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">,</span> <span class="s">"Hello World"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">expireResult4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">expireResult5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ttl</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">expireResult5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; -1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">expireResult6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">expire</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">,</span> <span class="mi">10</span><span class="o">,</span> <span class="n">ExpiryOption</span><span class="o">.</span><span class="na">XX</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">expireResult6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">expireResult7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ttl</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">expireResult7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; -1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">expireResult8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">expire</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">,</span> <span class="mi">10</span><span class="o">,</span> <span class="n">ExpiryOption</span><span class="o">.</span><span class="na">NX</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">expireResult8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">expireResult9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ttl</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">expireResult9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 10 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="c1">// Tests for 'expire' step. </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">ttlResult1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">,</span> <span class="s">"Hello"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">ttlResult1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">ttlResult2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">expire</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">,</span> <span class="mi">10</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">ttlResult2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">ttlResult3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ttl</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">ttlResult3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 10 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="c1">// Tests for 'ttl' step. </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_cmds_generic-stepscan3')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_cmds_generic-stepscan3" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/CmdsGenericExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_cmds_generic-stepscan3" name="cmds_generic-stepscan3" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_cmds_generic-stepscan3" title="Open example"> Go </label> <div aria-labelledby="tab-cmds_generic-stepscan3" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_cmds_generic-stepscan3" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> <span class="s">"math"</span> </span></span><span class="line"><span class="cl"> <span class="s">"time"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_del_cmd</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">delResult1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"key1"</span><span class="p">,</span> <span class="s">"Hello"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">delResult1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">delResult2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"key2"</span><span class="p">,</span> <span class="s">"World"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">delResult2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">delResult3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Del</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"key1"</span><span class="p">,</span> <span class="s">"key2"</span><span class="p">,</span> <span class="s">"key3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">delResult3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_expire_cmd</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">expireResult1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">,</span> <span class="s">"Hello"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">expireResult1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">expireResult2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Expire</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">,</span> <span class="mi">10</span><span class="o">*</span><span class="nx">time</span><span class="p">.</span><span class="nx">Second</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">expireResult2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">expireResult3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TTL</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nf">Round</span><span class="p">(</span><span class="nx">expireResult3</span><span class="p">.</span><span class="nf">Seconds</span><span class="p">()))</span> <span class="c1">// &gt;&gt;&gt; 10 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">expireResult4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">,</span> <span class="s">"Hello World"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">expireResult4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">expireResult5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TTL</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">expireResult5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; -1ns </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">expireResult6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">ExpireXX</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">,</span> <span class="mi">10</span><span class="o">*</span><span class="nx">time</span><span class="p">.</span><span class="nx">Second</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">expireResult6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">expireResult7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TTL</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">expireResult7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; -1ns </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">expireResult8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">ExpireNX</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">,</span> <span class="mi">10</span><span class="o">*</span><span class="nx">time</span><span class="p">.</span><span class="nx">Second</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">expireResult8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">expireResult9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TTL</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nf">Round</span><span class="p">(</span><span class="nx">expireResult9</span><span class="p">.</span><span class="nf">Seconds</span><span class="p">()))</span> <span class="c1">// &gt;&gt;&gt; 10 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ttl_cmd</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">ttlResult1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">,</span> <span class="s">"Hello"</span><span class="p">,</span> <span class="mi">10</span><span class="o">*</span><span class="nx">time</span><span class="p">.</span><span class="nx">Second</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">ttlResult1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">ttlResult2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TTL</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nf">Round</span><span class="p">(</span><span class="nx">ttlResult2</span><span class="p">.</span><span class="nf">Seconds</span><span class="p">()))</span> <span class="c1">// &gt;&gt;&gt; 10 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_cmds_generic-stepscan3')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_cmds_generic-stepscan3" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/cmds_generic_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_cmds_generic-stepscan3" name="cmds_generic-stepscan3" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_cmds_generic-stepscan3" title="Open example"> C# </label> <div aria-labelledby="tab-cmds_generic-stepscan3" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_cmds_generic-stepscan3" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Tests</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">StackExchange.Redis</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">CmdsGenericExample</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'copy' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">delResult1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"key1"</span><span class="p">,</span> <span class="s">"Hello"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">delResult1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">delResult2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"key2"</span><span class="p">,</span> <span class="s">"World"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">delResult2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">delResult3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyDelete</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"key1"</span><span class="p">,</span> <span class="s">"key2"</span><span class="p">,</span> <span class="s">"key3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">delResult3</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'del' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'dump' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'exists' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">expireResult1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">,</span> <span class="s">"Hello"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">expireResult1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">expireResult2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExpire</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">,</span> <span class="k">new</span> <span class="n">TimeSpan</span><span class="p">(</span><span class="m">0</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">10</span><span class="p">));</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">expireResult2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">TimeSpan</span> <span class="n">expireResult3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyTimeToLive</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">)</span> <span class="p">??</span> <span class="n">TimeSpan</span><span class="p">.</span><span class="n">Zero</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">Math</span><span class="p">.</span><span class="n">Round</span><span class="p">(</span><span class="n">expireResult3</span><span class="p">.</span><span class="n">TotalSeconds</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 10</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">expireResult4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">,</span> <span class="s">"Hello World"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">expireResult4</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">TimeSpan</span> <span class="n">expireResult5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyTimeToLive</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">)</span> <span class="p">??</span> <span class="n">TimeSpan</span><span class="p">.</span><span class="n">Zero</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">Math</span><span class="p">.</span><span class="n">Round</span><span class="p">(</span><span class="n">expireResult5</span><span class="p">.</span><span class="n">TotalSeconds</span><span class="p">).</span><span class="n">ToString</span><span class="p">());</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">expireResult6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExpire</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">,</span> <span class="k">new</span> <span class="n">TimeSpan</span><span class="p">(</span><span class="m">0</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">10</span><span class="p">),</span> <span class="n">ExpireWhen</span><span class="p">.</span><span class="n">HasExpiry</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">expireResult6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; false</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">TimeSpan</span> <span class="n">expireResult7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyTimeToLive</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">)</span> <span class="p">??</span> <span class="n">TimeSpan</span><span class="p">.</span><span class="n">Zero</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">Math</span><span class="p">.</span><span class="n">Round</span><span class="p">(</span><span class="n">expireResult7</span><span class="p">.</span><span class="n">TotalSeconds</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">expireResult8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExpire</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">,</span> <span class="k">new</span> <span class="n">TimeSpan</span><span class="p">(</span><span class="m">0</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">10</span><span class="p">),</span> <span class="n">ExpireWhen</span><span class="p">.</span><span class="n">HasNoExpiry</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">expireResult8</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">TimeSpan</span> <span class="n">expireResult9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyTimeToLive</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">)</span> <span class="p">??</span> <span class="n">TimeSpan</span><span class="p">.</span><span class="n">Zero</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">Math</span><span class="p">.</span><span class="n">Round</span><span class="p">(</span><span class="n">expireResult9</span><span class="p">.</span><span class="n">TotalSeconds</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 10</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'expire' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'expireat' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'expiretime' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'keys' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'migrate' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'move' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'object_encoding' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'object_freq' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'object_idletime' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'object_refcount' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'persist' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'pexpire' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'pexpireat' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'pexpiretime' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'pttl' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'randomkey' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'rename' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'renamenx' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'restore' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'scan1' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'scan2' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'scan3' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'scan4' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sort' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sort_ro' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'touch' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">ttlResult1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">,</span> <span class="s">"Hello"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">ttlResult1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">ttlResult2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExpire</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">,</span> <span class="k">new</span> <span class="n">TimeSpan</span><span class="p">(</span><span class="m">0</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">10</span><span class="p">));</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">ttlResult2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">TimeSpan</span> <span class="n">ttlResult3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyTimeToLive</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">)</span> <span class="p">??</span> <span class="n">TimeSpan</span><span class="p">.</span><span class="n">Zero</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> <span class="kt">string</span> <span class="n">ttlRes</span> <span class="p">=</span> <span class="n">Math</span><span class="p">.</span><span class="n">Round</span><span class="p">(</span><span class="n">ttlResult3</span><span class="p">.</span><span class="n">TotalSeconds</span><span class="p">).</span><span class="n">ToString</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">Math</span><span class="p">.</span><span class="n">Round</span><span class="p">(</span><span class="n">ttlResult3</span><span class="p">.</span><span class="n">TotalSeconds</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 10</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'ttl' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'type' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'unlink' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'wait' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'waitaof' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_cmds_generic-stepscan3')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_cmds_generic-stepscan3" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/CmdsGenericExample.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <p> It is important to note that the <strong> TYPE </strong> filter is also applied after elements are retrieved from the database, so the option does not reduce the amount of work the server has to do to complete a full iteration, and for rare types you may receive no elements in many iterations. </p> <h2 id="the-novalues-option"> The NOVALUES option </h2> <p> When using <a href="/docs/latest/commands/hscan/"> <code> HSCAN </code> </a> , you can use the <code> NOVALUES </code> option to make Redis return only the keys in the hash table without their corresponding values. </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="cmds_generic-stepscan4"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_cmds_generic-stepscan4" name="cmds_generic-stepscan4" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_cmds_generic-stepscan4" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-cmds_generic-stepscan4" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_cmds_generic-stepscan4" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; HSET myhash a 1 b 2 </span></span><span class="line hl"><span class="cl">OK </span></span><span class="line hl"><span class="cl">&gt; HSCAN myhash 0 </span></span><span class="line hl"><span class="cl">1) "0" </span></span><span class="line hl"><span class="cl">2) 1) "a" </span></span><span class="line hl"><span class="cl"> 2) "1" </span></span><span class="line hl"><span class="cl"> 3) "b" </span></span><span class="line hl"><span class="cl"> 4) "2" </span></span><span class="line hl"><span class="cl">&gt; HSCAN myhash 0 NOVALUES </span></span><span class="line hl"><span class="cl">1) "0" </span></span><span class="line hl"><span class="cl">2) 1) "a" </span></span><span class="line hl"><span class="cl"> 2) "b"</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_cmds_generic-stepscan4')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_cmds_generic-stepscan4" name="cmds_generic-stepscan4" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_cmds_generic-stepscan4" title="Open example"> Python </label> <div aria-labelledby="tab-cmds_generic-stepscan4" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_cmds_generic-stepscan4" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"key1"</span><span class="p">,</span> <span class="s2">"Hello"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"key2"</span><span class="p">,</span> <span class="s2">"World"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"key1"</span><span class="p">,</span> <span class="s2">"key2"</span><span class="p">,</span> <span class="s2">"key3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">,</span> <span class="s2">"Hello"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">expire</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ttl</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; 10</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">,</span> <span class="s2">"Hello World"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ttl</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; -1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">expire</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="n">xx</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ttl</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; -1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">expire</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="n">nx</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ttl</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; 10</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">,</span> <span class="s2">"Hello"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">expire</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ttl</span><span class="p">(</span><span class="s2">"mykey"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; 10</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"myset"</span><span class="p">,</span> <span class="o">*</span><span class="nb">set</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="s2">"foo"</span><span class="p">,</span> <span class="s2">"foobar"</span><span class="p">,</span> <span class="s2">"feelsgood"</span><span class="p">]))</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; 6</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">r</span><span class="o">.</span><span class="n">sscan_iter</span><span class="p">(</span><span class="s2">"myset"</span><span class="p">,</span> <span class="n">match</span><span class="o">=</span><span class="s2">"f*"</span><span class="p">))</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; ['foobar', 'foo', 'feelsgood']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">cursor</span><span class="p">,</span> <span class="n">key</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">scan</span><span class="p">(</span><span class="n">cursor</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">match</span><span class="o">=</span><span class="s1">'*11*'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">cursor</span><span class="p">,</span> <span class="n">key</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">cursor</span><span class="p">,</span> <span class="n">key</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">scan</span><span class="p">(</span><span class="n">cursor</span><span class="p">,</span> <span class="n">match</span><span class="o">=</span><span class="s1">'*11*'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">cursor</span><span class="p">,</span> <span class="n">key</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">cursor</span><span class="p">,</span> <span class="n">key</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">scan</span><span class="p">(</span><span class="n">cursor</span><span class="p">,</span> <span class="n">match</span><span class="o">=</span><span class="s1">'*11*'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">cursor</span><span class="p">,</span> <span class="n">key</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">cursor</span><span class="p">,</span> <span class="n">key</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">scan</span><span class="p">(</span><span class="n">cursor</span><span class="p">,</span> <span class="n">match</span><span class="o">=</span><span class="s1">'*11*'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">cursor</span><span class="p">,</span> <span class="n">key</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">cursor</span><span class="p">,</span> <span class="n">keys</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">scan</span><span class="p">(</span><span class="n">cursor</span><span class="p">,</span> <span class="n">match</span><span class="o">=</span><span class="s1">'*11*'</span><span class="p">,</span> <span class="n">count</span><span class="o">=</span><span class="mi">1000</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">cursor</span><span class="p">,</span> <span class="n">keys</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">geoadd</span><span class="p">(</span><span class="s2">"geokey"</span><span class="p">,</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="s2">"value"</span><span class="p">))</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">zadd</span><span class="p">(</span><span class="s2">"zkey"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"value"</span><span class="p">:</span> <span class="mi">1000</span><span class="p">})</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">type</span><span class="p">(</span><span class="s2">"geokey"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; zset</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">type</span><span class="p">(</span><span class="s2">"zkey"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; zset</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">cursor</span><span class="p">,</span> <span class="n">keys</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">scan</span><span class="p">(</span><span class="n">cursor</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">_type</span><span class="o">=</span><span class="s2">"zset"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">keys</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; ['zkey', 'geokey']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">hset</span><span class="p">(</span><span class="s2">"myhash"</span><span class="p">,</span> <span class="n">mapping</span><span class="o">=</span><span class="p">{</span><span class="s2">"a"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"b"</span><span class="p">:</span> <span class="mi">2</span><span class="p">})</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">cursor</span><span class="p">,</span> <span class="n">keys</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">hscan</span><span class="p">(</span><span class="s2">"myhash"</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">keys</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="c1"># &gt;&gt;&gt; {'a': '1', 'b': '2'}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">cursor</span><span class="p">,</span> <span class="n">keys</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">hscan</span><span class="p">(</span><span class="s2">"myhash"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">no_values</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">keys</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="c1"># &gt;&gt;&gt; ['a', 'b']</span> </span></span><span class="line hl"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_cmds_generic-stepscan4')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_cmds_generic-stepscan4" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/cmds_generic.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_cmds_generic-stepscan4" name="cmds_generic-stepscan4" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_cmds_generic-stepscan4" title="Open example"> Node.js </label> <div aria-labelledby="tab-cmds_generic-stepscan4" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_cmds_generic-stepscan4" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">createClient</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">().</span><span class="k">catch</span><span class="p">(</span><span class="nx">console</span><span class="p">.</span><span class="nx">error</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">delRes1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">'key1'</span><span class="p">,</span> <span class="s1">'Hello'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">delRes1</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">delRes2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">'key2'</span><span class="p">,</span> <span class="s1">'World'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">delRes2</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">delRes3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">([</span><span class="s1">'key1'</span><span class="p">,</span> <span class="s1">'key2'</span><span class="p">,</span> <span class="s1">'key3'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">delRes3</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">expireRes1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">,</span> <span class="s1">'Hello'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">expireRes1</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">expireRes2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">expire</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">,</span> <span class="mi">10</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">expireRes2</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">expireRes3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ttl</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">expireRes3</span><span class="p">);</span> <span class="c1">// 10 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">expireRes4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">,</span> <span class="s1">'Hello World'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">expireRes4</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">expireRes5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ttl</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">expireRes5</span><span class="p">);</span> <span class="c1">// -1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">expireRes6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">expire</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="s2">"XX"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">expireRes6</span><span class="p">);</span> <span class="c1">// false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">expireRes7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ttl</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">expireRes7</span><span class="p">);</span> <span class="c1">// -1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">expireRes8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">expire</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="s2">"NX"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">expireRes8</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">expireRes9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ttl</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">expireRes9</span><span class="p">);</span> <span class="c1">// 10 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">ttlRes1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">,</span> <span class="s1">'Hello'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">ttlRes1</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">ttlRes2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">expire</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">,</span> <span class="mi">10</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">ttlRes2</span><span class="p">);</span> <span class="c1">// true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">ttlRes3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ttl</span><span class="p">(</span><span class="s1">'mykey'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">ttlRes3</span><span class="p">);</span> <span class="c1">// 10 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">scan1Res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'myset'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'1'</span><span class="p">,</span> <span class="s1">'2'</span><span class="p">,</span> <span class="s1">'3'</span><span class="p">,</span> <span class="s1">'foo'</span><span class="p">,</span> <span class="s1">'foobar'</span><span class="p">,</span> <span class="s1">'feelsgood'</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scan1Res1</span><span class="p">);</span> <span class="c1">// 6 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">scan1Res2</span> <span class="o">=</span> <span class="p">[];</span> </span></span><span class="line"><span class="cl"><span class="k">for</span> <span class="kr">await</span> <span class="p">(</span><span class="kr">const</span> <span class="nx">value</span> <span class="k">of</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sScanIterator</span><span class="p">(</span><span class="s1">'myset'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">MATCH</span><span class="o">:</span> <span class="s1">'f*'</span> <span class="p">}))</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">scan1Res2</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">value</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scan1Res2</span><span class="p">);</span> <span class="c1">// ['foo', 'foobar', 'feelsgood'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kd">let</span> <span class="nx">cursor</span> <span class="o">=</span> <span class="s1">'0'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kd">let</span> <span class="nx">scanResult</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="nx">scanResult</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">scan</span><span class="p">(</span><span class="nx">cursor</span><span class="p">,</span> <span class="p">{</span> <span class="nx">MATCH</span><span class="o">:</span> <span class="s1">'*11*'</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scanResult</span><span class="p">.</span><span class="nx">cursor</span><span class="p">,</span> <span class="nx">scanResult</span><span class="p">.</span><span class="nx">keys</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="nx">scanResult</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">scan</span><span class="p">(</span><span class="nx">scanResult</span><span class="p">.</span><span class="nx">cursor</span><span class="p">,</span> <span class="p">{</span> <span class="nx">MATCH</span><span class="o">:</span> <span class="s1">'*11*'</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scanResult</span><span class="p">.</span><span class="nx">cursor</span><span class="p">,</span> <span class="nx">scanResult</span><span class="p">.</span><span class="nx">keys</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="nx">scanResult</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">scan</span><span class="p">(</span><span class="nx">scanResult</span><span class="p">.</span><span class="nx">cursor</span><span class="p">,</span> <span class="p">{</span> <span class="nx">MATCH</span><span class="o">:</span> <span class="s1">'*11*'</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scanResult</span><span class="p">.</span><span class="nx">cursor</span><span class="p">,</span> <span class="nx">scanResult</span><span class="p">.</span><span class="nx">keys</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="nx">scanResult</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">scan</span><span class="p">(</span><span class="nx">scanResult</span><span class="p">.</span><span class="nx">cursor</span><span class="p">,</span> <span class="p">{</span> <span class="nx">MATCH</span><span class="o">:</span> <span class="s1">'*11*'</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scanResult</span><span class="p">.</span><span class="nx">cursor</span><span class="p">,</span> <span class="nx">scanResult</span><span class="p">.</span><span class="nx">keys</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="nx">scanResult</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">scan</span><span class="p">(</span><span class="nx">scanResult</span><span class="p">.</span><span class="nx">cursor</span><span class="p">,</span> <span class="p">{</span> <span class="nx">MATCH</span><span class="o">:</span> <span class="s1">'*11*'</span><span class="p">,</span> <span class="nx">COUNT</span><span class="o">:</span> <span class="mi">1000</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scanResult</span><span class="p">.</span><span class="nx">cursor</span><span class="p">,</span> <span class="nx">scanResult</span><span class="p">.</span><span class="nx">keys</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">scan3Res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">geoAdd</span><span class="p">(</span><span class="s1">'geokey'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">longitude</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">latitude</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">member</span><span class="o">:</span> <span class="s1">'value'</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scan3Res1</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">scan3Res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zAdd</span><span class="p">(</span><span class="s1">'zkey'</span><span class="p">,</span> <span class="p">[{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">1000</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'value'</span> <span class="p">}]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scan3Res2</span><span class="p">);</span> <span class="c1">// 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">scan3Res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">type</span><span class="p">(</span><span class="s1">'geokey'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scan3Res3</span><span class="p">);</span> <span class="c1">// zset </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">scan3Res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">type</span><span class="p">(</span><span class="s1">'zkey'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scan3Res4</span><span class="p">);</span> <span class="c1">// zset </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">scan3Res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">scan</span><span class="p">(</span><span class="s1">'0'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">TYPE</span><span class="o">:</span> <span class="s1">'zset'</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scan3Res5</span><span class="p">.</span><span class="nx">keys</span><span class="p">);</span> <span class="c1">// ['zkey', 'geokey'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">scan4Res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">hSet</span><span class="p">(</span><span class="s1">'myhash'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">a</span><span class="o">:</span> <span class="mi">1</span><span class="p">,</span> <span class="nx">b</span><span class="o">:</span> <span class="mi">2</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scan4Res1</span><span class="p">);</span> <span class="c1">// 2 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">scan4Res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">hScan</span><span class="p">(</span><span class="s1">'myhash'</span><span class="p">,</span> <span class="mi">0</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">scan4Res2</span><span class="p">.</span><span class="nx">tuples</span><span class="p">);</span> <span class="c1">// [{field: 'a', value: '1'}, {field: 'b', value: '2'}] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">scan4Res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">hScan</span><span class="p">(</span><span class="s1">'myhash'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="p">{</span> <span class="nx">COUNT</span><span class="o">:</span> <span class="mi">10</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">items</span> <span class="o">=</span> <span class="nx">scan4Res3</span><span class="p">.</span><span class="nx">tuples</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">item</span><span class="p">)</span> <span class="p">=&gt;</span> <span class="nx">item</span><span class="p">.</span><span class="nx">field</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">items</span><span class="p">);</span> <span class="c1">// ['a', 'b'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">quit</span><span class="p">();</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_cmds_generic-stepscan4')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_cmds_generic-stepscan4" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/cmds-generic.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_cmds_generic-stepscan4" name="cmds_generic-stepscan4" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_cmds_generic-stepscan4" title="Open example"> Java </label> <div aria-labelledby="tab-cmds_generic-stepscan4" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_cmds_generic-stepscan4" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.args.ExpiryOption</span><span class="o">;</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">CmdsGenericExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">delResult1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"key1"</span><span class="o">,</span> <span class="s">"Hello"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">delResult1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">delResult2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"key2"</span><span class="o">,</span> <span class="s">"World"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">delResult2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">delResult3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">del</span><span class="o">(</span><span class="s">"key1"</span><span class="o">,</span> <span class="s">"key2"</span><span class="o">,</span> <span class="s">"key3"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">delResult3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="c1">// Tests for 'del' step. </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">expireResult1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">,</span> <span class="s">"Hello"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">expireResult1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">expireResult2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">expire</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">,</span> <span class="mi">10</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">expireResult2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">expireResult3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ttl</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">expireResult3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 10 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">expireResult4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">,</span> <span class="s">"Hello World"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">expireResult4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">expireResult5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ttl</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">expireResult5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; -1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">expireResult6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">expire</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">,</span> <span class="mi">10</span><span class="o">,</span> <span class="n">ExpiryOption</span><span class="o">.</span><span class="na">XX</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">expireResult6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">expireResult7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ttl</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">expireResult7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; -1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">expireResult8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">expire</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">,</span> <span class="mi">10</span><span class="o">,</span> <span class="n">ExpiryOption</span><span class="o">.</span><span class="na">NX</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">expireResult8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">expireResult9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ttl</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">expireResult9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 10 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="c1">// Tests for 'expire' step. </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">ttlResult1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">,</span> <span class="s">"Hello"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">ttlResult1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">ttlResult2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">expire</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">,</span> <span class="mi">10</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">ttlResult2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">ttlResult3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ttl</span><span class="o">(</span><span class="s">"mykey"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">ttlResult3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 10 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="c1">// Tests for 'ttl' step. </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_cmds_generic-stepscan4')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_cmds_generic-stepscan4" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/CmdsGenericExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_cmds_generic-stepscan4" name="cmds_generic-stepscan4" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_cmds_generic-stepscan4" title="Open example"> Go </label> <div aria-labelledby="tab-cmds_generic-stepscan4" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_cmds_generic-stepscan4" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> <span class="s">"math"</span> </span></span><span class="line"><span class="cl"> <span class="s">"time"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_del_cmd</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">delResult1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"key1"</span><span class="p">,</span> <span class="s">"Hello"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">delResult1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">delResult2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"key2"</span><span class="p">,</span> <span class="s">"World"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">delResult2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">delResult3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Del</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"key1"</span><span class="p">,</span> <span class="s">"key2"</span><span class="p">,</span> <span class="s">"key3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">delResult3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_expire_cmd</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">expireResult1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">,</span> <span class="s">"Hello"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">expireResult1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">expireResult2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Expire</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">,</span> <span class="mi">10</span><span class="o">*</span><span class="nx">time</span><span class="p">.</span><span class="nx">Second</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">expireResult2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">expireResult3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TTL</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nf">Round</span><span class="p">(</span><span class="nx">expireResult3</span><span class="p">.</span><span class="nf">Seconds</span><span class="p">()))</span> <span class="c1">// &gt;&gt;&gt; 10 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">expireResult4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">,</span> <span class="s">"Hello World"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">expireResult4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">expireResult5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TTL</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">expireResult5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; -1ns </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">expireResult6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">ExpireXX</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">,</span> <span class="mi">10</span><span class="o">*</span><span class="nx">time</span><span class="p">.</span><span class="nx">Second</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">expireResult6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">expireResult7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TTL</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">expireResult7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; -1ns </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">expireResult8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">ExpireNX</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">,</span> <span class="mi">10</span><span class="o">*</span><span class="nx">time</span><span class="p">.</span><span class="nx">Second</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">expireResult8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">expireResult9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TTL</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nf">Round</span><span class="p">(</span><span class="nx">expireResult9</span><span class="p">.</span><span class="nf">Seconds</span><span class="p">()))</span> <span class="c1">// &gt;&gt;&gt; 10 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_ttl_cmd</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">ttlResult1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">,</span> <span class="s">"Hello"</span><span class="p">,</span> <span class="mi">10</span><span class="o">*</span><span class="nx">time</span><span class="p">.</span><span class="nx">Second</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">ttlResult1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">ttlResult2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TTL</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"mykey"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">math</span><span class="p">.</span><span class="nf">Round</span><span class="p">(</span><span class="nx">ttlResult2</span><span class="p">.</span><span class="nf">Seconds</span><span class="p">()))</span> <span class="c1">// &gt;&gt;&gt; 10 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_cmds_generic-stepscan4')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_cmds_generic-stepscan4" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/cmds_generic_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_cmds_generic-stepscan4" name="cmds_generic-stepscan4" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_cmds_generic-stepscan4" title="Open example"> C# </label> <div aria-labelledby="tab-cmds_generic-stepscan4" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_cmds_generic-stepscan4" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Tests</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">StackExchange.Redis</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">CmdsGenericExample</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'copy' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">delResult1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"key1"</span><span class="p">,</span> <span class="s">"Hello"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">delResult1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">delResult2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"key2"</span><span class="p">,</span> <span class="s">"World"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">delResult2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">delResult3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyDelete</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"key1"</span><span class="p">,</span> <span class="s">"key2"</span><span class="p">,</span> <span class="s">"key3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">delResult3</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'del' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'dump' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'exists' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">expireResult1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">,</span> <span class="s">"Hello"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">expireResult1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">expireResult2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExpire</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">,</span> <span class="k">new</span> <span class="n">TimeSpan</span><span class="p">(</span><span class="m">0</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">10</span><span class="p">));</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">expireResult2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">TimeSpan</span> <span class="n">expireResult3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyTimeToLive</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">)</span> <span class="p">??</span> <span class="n">TimeSpan</span><span class="p">.</span><span class="n">Zero</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">Math</span><span class="p">.</span><span class="n">Round</span><span class="p">(</span><span class="n">expireResult3</span><span class="p">.</span><span class="n">TotalSeconds</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 10</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">expireResult4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">,</span> <span class="s">"Hello World"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">expireResult4</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">TimeSpan</span> <span class="n">expireResult5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyTimeToLive</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">)</span> <span class="p">??</span> <span class="n">TimeSpan</span><span class="p">.</span><span class="n">Zero</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">Math</span><span class="p">.</span><span class="n">Round</span><span class="p">(</span><span class="n">expireResult5</span><span class="p">.</span><span class="n">TotalSeconds</span><span class="p">).</span><span class="n">ToString</span><span class="p">());</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">expireResult6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExpire</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">,</span> <span class="k">new</span> <span class="n">TimeSpan</span><span class="p">(</span><span class="m">0</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">10</span><span class="p">),</span> <span class="n">ExpireWhen</span><span class="p">.</span><span class="n">HasExpiry</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">expireResult6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; false</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">TimeSpan</span> <span class="n">expireResult7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyTimeToLive</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">)</span> <span class="p">??</span> <span class="n">TimeSpan</span><span class="p">.</span><span class="n">Zero</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">Math</span><span class="p">.</span><span class="n">Round</span><span class="p">(</span><span class="n">expireResult7</span><span class="p">.</span><span class="n">TotalSeconds</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">expireResult8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExpire</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">,</span> <span class="k">new</span> <span class="n">TimeSpan</span><span class="p">(</span><span class="m">0</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">10</span><span class="p">),</span> <span class="n">ExpireWhen</span><span class="p">.</span><span class="n">HasNoExpiry</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">expireResult8</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">TimeSpan</span> <span class="n">expireResult9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyTimeToLive</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">)</span> <span class="p">??</span> <span class="n">TimeSpan</span><span class="p">.</span><span class="n">Zero</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">Math</span><span class="p">.</span><span class="n">Round</span><span class="p">(</span><span class="n">expireResult9</span><span class="p">.</span><span class="n">TotalSeconds</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 10</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'expire' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'expireat' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'expiretime' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'keys' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'migrate' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'move' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'object_encoding' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'object_freq' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'object_idletime' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'object_refcount' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'persist' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'pexpire' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'pexpireat' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'pexpiretime' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'pttl' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'randomkey' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'rename' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'renamenx' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'restore' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'scan1' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'scan2' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'scan3' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'scan4' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sort' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sort_ro' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'touch' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">ttlResult1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">,</span> <span class="s">"Hello"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">ttlResult1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">ttlResult2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyExpire</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">,</span> <span class="k">new</span> <span class="n">TimeSpan</span><span class="p">(</span><span class="m">0</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">10</span><span class="p">));</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">ttlResult2</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">TimeSpan</span> <span class="n">ttlResult3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">KeyTimeToLive</span><span class="p">(</span><span class="s">"mykey"</span><span class="p">)</span> <span class="p">??</span> <span class="n">TimeSpan</span><span class="p">.</span><span class="n">Zero</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> <span class="kt">string</span> <span class="n">ttlRes</span> <span class="p">=</span> <span class="n">Math</span><span class="p">.</span><span class="n">Round</span><span class="p">(</span><span class="n">ttlResult3</span><span class="p">.</span><span class="n">TotalSeconds</span><span class="p">).</span><span class="n">ToString</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">Math</span><span class="p">.</span><span class="n">Round</span><span class="p">(</span><span class="n">ttlResult3</span><span class="p">.</span><span class="n">TotalSeconds</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 10</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'ttl' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'type' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'unlink' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'wait' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'waitaof' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_cmds_generic-stepscan4')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_cmds_generic-stepscan4" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/CmdsGenericExample.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <h2 id="multiple-parallel-iterations"> Multiple parallel iterations </h2> <p> It is possible for an infinite number of clients to iterate the same collection at the same time, as the full state of the iterator is in the cursor, that is obtained and returned to the client at every call. No server side state is taken at all. </p> <h2 id="terminating-iterations-in-the-middle"> Terminating iterations in the middle </h2> <p> Since there is no state server side, but the full state is captured by the cursor, the caller is free to terminate an iteration half-way without signaling this to the server in any way. An infinite number of iterations can be started and never terminated without any issue. </p> <h2 id="calling-scan-with-a-corrupted-cursor"> Calling SCAN with a corrupted cursor </h2> <p> Calling <code> SCAN </code> with a broken, negative, out of range, or otherwise invalid cursor, will result in undefined behavior but never in a crash. What will be undefined is that the guarantees about the returned elements can no longer be ensured by the <code> SCAN </code> implementation. </p> <p> The only valid cursors to use are: </p> <ul> <li> The cursor value of 0 when starting an iteration. </li> <li> The cursor returned by the previous call to SCAN in order to continue the iteration. </li> </ul> <h2 id="guarantee-of-termination"> Guarantee of termination </h2> <p> The <code> SCAN </code> algorithm is guaranteed to terminate only if the size of the iterated collection remains bounded to a given maximum size, otherwise iterating a collection that always grows may result into <code> SCAN </code> to never terminate a full iteration. </p> <p> This is easy to see intuitively: if the collection grows there is more and more work to do in order to visit all the possible elements, and the ability to terminate the iteration depends on the number of calls to <code> SCAN </code> and its COUNT option value compared with the rate at which the collection grows. </p> <h2 id="why-scan-may-return-all-the-items-of-an-aggregate-data-type-in-a-single-call"> Why SCAN may return all the items of an aggregate data type in a single call? </h2> <p> In the <code> COUNT </code> option documentation, we state that sometimes this family of commands may return all the elements of a Set, Hash or Sorted Set at once in a single call, regardless of the <code> COUNT </code> option value. The reason why this happens is that the cursor-based iterator can be implemented, and is useful, only when the aggregate data type that we are scanning is represented as a hash table. However Redis uses a <a href="/docs/latest/operate/oss_and_stack/management/optimization/memory-optimization/"> memory optimization </a> where small aggregate data types, until they reach a given amount of items or a given max size of single elements, are represented using a compact single-allocation packed encoding. When this is the case, <code> SCAN </code> has no meaningful cursor to return, and must iterate the whole data structure at once, so the only sane behavior it has is to return everything in a call. </p> <p> However once the data structures are bigger and are promoted to use real hash tables, the <code> SCAN </code> family of commands will resort to the normal behavior. Note that since this special behavior of returning all the elements is true only for small aggregates, it has no effects on the command complexity or latency. However the exact limits to get converted into real hash tables are <a href="/docs/latest/operate/oss_and_stack/management/optimization/memory-optimization/"> user configurable </a> , so the maximum number of elements you can see returned in a single call depends on how big an aggregate data type could be and still use the packed representation. </p> <p> Also note that this behavior is specific of <a href="/docs/latest/commands/sscan/"> <code> SSCAN </code> </a> , <a href="/docs/latest/commands/hscan/"> <code> HSCAN </code> </a> and <a href="/docs/latest/commands/zscan/"> <code> ZSCAN </code> </a> . <code> SCAN </code> itself never shows this behavior because the key space is always represented by hash tables. </p> <h2 id="further-reading"> Further reading </h2> <p> For more information about managing keys, please refer to the <a href="/docs/latest/develop/use/keyspace/"> The Redis Keyspace </a> tutorial. </p> <h2 id="additional-examples"> Additional examples </h2> <p> Give the following commands, showing iteration of a hash key, a try in the interactive console: </p> <div class="bg-slate-900 border-b border-slate-700 rounded-t-xl px-4 py-3 w-full flex"> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M2.5 10C2.5 5.85786 5.85786 2.5 10 2.5C14.1421 2.5 17.5 5.85786 17.5 10C17.5 14.1421 14.1421 17.5 10 17.5C5.85786 17.5 2.5 14.1421 2.5 10Z"> </path> </svg> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M10 2.5L18.6603 17.5L1.33975 17.5L10 2.5Z"> </path> </svg> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M10 2.5L12.0776 7.9322L17.886 8.22949L13.3617 11.8841L14.8738 17.5L10 14.3264L5.1262 17.5L6.63834 11.8841L2.11403 8.22949L7.92238 7.9322L10 2.5Z"> </path> </svg> </div> <form class="redis-cli overflow-y-auto max-h-80"> <pre tabindex="0">redis&gt; HMSET hash name Jack age 33 "OK" redis&gt; HSCAN hash 0 1) "0" 2) 1) "name" 2) "Jack" 3) "age" 4) "33" </pre> <div class="prompt" style=""> <span> redis&gt; </span> <input autocomplete="off" name="prompt" spellcheck="false" type="text"/> </div> </form> <h2 id="resp2resp3-reply"> RESP2/RESP3 Reply </h2> <p> <a href="../../develop/reference/protocol-spec#arrays"> Array reply </a> : specifically, an array with two elements. </p> <ul> <li> The first element is a <a href="../../develop/reference/protocol-spec#bulk-strings"> Bulk string reply </a> that represents an unsigned 64-bit number, the cursor. </li> <li> The second element is an <a href="../../develop/reference/protocol-spec#arrays"> Array reply </a> with the names of scanned keys. </li> </ul> <br/> <h2> History </h2> <ul> <li> Starting with Redis version 6.0.0: Added the <code> TYPE </code> subcommand. </li> </ul> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/scan/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/bf.card.html
<section class="prose w-full py-12"> <h1 class="command-name"> BF.CARD </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">BF.CARD key</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available in: </dt> <dd class="m-0"> <a href="/docs/stack"> Redis Stack </a> / <a href="/docs/data-types/probabilistic"> Bloom 2.4.4 </a> </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(1) </dd> </dl> <p> Returns the cardinality of a Bloom filter - number of items that were added to a Bloom filter and detected as unique (items that caused at least one bit to be set in at least one sub-filter) </p> <p> (since RedisBloom 2.4.4) </p> <h2 id="required-arguments"> Required arguments </h2> <details open=""> <summary> <code> key </code> </summary> <p> is key name for a Bloom filter. </p> </details> <h2 id="return-value"> Return value </h2> <p> Returns one of these replies: </p> <ul> <li> <a href="/docs/latest/develop/reference/protocol-spec/#integers"> Integer reply </a> - the number of items that were added to this Bloom filter and detected as unique (items that caused at least one bit to be set in at least one sub-filter), or 0 when <code> key </code> does not exist. </li> <li> [] on error (invalid arguments, wrong key type, etc.) </li> </ul> <p> Note: when <code> key </code> exists - return the same value as <code> BF.INFO key ITEMS </code> . </p> <h2 id="examples"> Examples </h2> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis&gt; BF.ADD bf1 item_foo </span></span><span class="line"><span class="cl"><span class="o">(</span>integer<span class="o">)</span> <span class="m">1</span> </span></span><span class="line"><span class="cl">redis&gt; BF.CARD bf1 </span></span><span class="line"><span class="cl"><span class="o">(</span>integer<span class="o">)</span> <span class="m">1</span> </span></span><span class="line"><span class="cl">redis&gt; BF.CARD bf_new </span></span><span class="line"><span class="cl"><span class="o">(</span>integer<span class="o">)</span> <span class="m">0</span></span></span></code></pre> </div> <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/bf.card/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/deprecated-features/triggers-and-functions/quick_start_cli/.html
<section class="prose w-full py-12 max-w-none"> <h1> Quick start using redis-cli </h1> <p class="text-lg -mt-5 mb-10"> Get started with triggers and functions using redis-cli </p> <div class="banner-article rounded-md"> <p> The Redis Stack triggers and functions feature preview has ended and it will not be promoted to GA. </p> </div> <p> Make sure that you have <a href="/docs/latest/operate/oss_and_stack/install/install-stack/"> Redis Stack installed </a> and running. Alternatively, you can create a <a href="https://redis.com/try-free/?utm_source=redisio&amp;utm_medium=referral&amp;utm_campaign=2023-09-try_free&amp;utm_content=cu-redis_cloud_users"> free Redis Cloud account </a> . The triggers and functions preview is available in the fixed subscription plan for the Google Cloud Asia Pacific (Tokyo) and AWS Asia Pacific (Singapore) regions. </p> <h2 id="connect-to-redis-stack"> Connect to Redis Stack </h2> <div class="highlight"> <pre class="chroma"><code class="language-Shell" data-lang="Shell"><span class="line"><span class="cl">&gt; redis-cli -h 127.0.0.1 -p <span class="m">6379</span> </span></span></code></pre> </div> <h2 id="load-a-library"> Load a library </h2> <p> Use the <code> TFUNCION LOAD </code> command to create a new library in your Redis instance. </p> <div class="highlight"> <pre class="chroma"><code class="language-Shell" data-lang="Shell"><span class="line"><span class="cl">127.0.0.1:6379&gt; TFUNCTION LOAD <span class="s2">"#!js api_version=1.0 name=myFirstLibrary\n redis.registerFunction('hello', ()=&gt;{ return 'Hello World'})"</span> </span></span><span class="line"><span class="cl">OK </span></span></code></pre> </div> <p> When the library is created successfully, an <code> OK </code> response is returned. Run the <code> TFUNCTION LIST </code> command to confirm your library was added to Redis. </p> <div class="highlight"> <pre class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">&gt; TFUNCTION LIST </span></span><span class="line"><span class="cl">1<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"api_version"</span> </span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"1.0"</span> </span></span><span class="line"><span class="cl"> 3<span class="o">)</span> <span class="s2">"cluster_functions"</span> </span></span><span class="line"><span class="cl"> 4<span class="o">)</span> <span class="o">(</span>empty list or <span class="nb">set</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> 5<span class="o">)</span> <span class="s2">"configuration"</span> </span></span><span class="line"><span class="cl"> 6<span class="o">)</span> <span class="s2">"null"</span> </span></span><span class="line"><span class="cl"> 7<span class="o">)</span> <span class="s2">"engine"</span> </span></span><span class="line"><span class="cl"> 8<span class="o">)</span> <span class="s2">"js"</span> </span></span><span class="line"><span class="cl"> 9<span class="o">)</span> <span class="s2">"functions"</span> </span></span><span class="line"><span class="cl"> 10<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"hello"</span> </span></span><span class="line"><span class="cl"> 11<span class="o">)</span> <span class="s2">"keyspace_triggers"</span> </span></span><span class="line"><span class="cl"> 12<span class="o">)</span> <span class="o">(</span>empty list or <span class="nb">set</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> 13<span class="o">)</span> <span class="s2">"name"</span> </span></span><span class="line"><span class="cl"> 14<span class="o">)</span> <span class="s2">"myFirstLibrary"</span> </span></span><span class="line"><span class="cl"> 15<span class="o">)</span> <span class="s2">"pending_async_calls"</span> </span></span><span class="line"><span class="cl"> 16<span class="o">)</span> <span class="o">(</span>empty list or <span class="nb">set</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> 17<span class="o">)</span> <span class="s2">"pending_jobs"</span> </span></span><span class="line"><span class="cl"> 18<span class="o">)</span> <span class="s2">"0"</span> </span></span><span class="line"><span class="cl"> 19<span class="o">)</span> <span class="s2">"stream_triggers"</span> </span></span><span class="line"><span class="cl"> 20<span class="o">)</span> <span class="o">(</span>empty list or <span class="nb">set</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> 21<span class="o">)</span> <span class="s2">"user"</span> </span></span><span class="line"><span class="cl"> 22<span class="o">)</span> <span class="s2">"default"</span> </span></span></code></pre> </div> <p> The <code> TFCALL </code> command is used to execute the JavaScript Function. If the command fails, an error will be returned. </p> <div class="highlight"> <pre class="chroma"><code class="language-Shell" data-lang="Shell"><span class="line"><span class="cl">127.0.0.1:6379&gt; TFCALL myFirstLibrary.hello <span class="m">0</span> </span></span><span class="line"><span class="cl"><span class="s2">"Hello World"</span> </span></span></code></pre> </div> <p> To update the library run the <code> TFUNCTION LOAD </code> command with the additional parameter <code> REPLACE </code> . </p> <div class="highlight"> <pre class="chroma"><code class="language-Shell" data-lang="Shell"><span class="line"><span class="cl">127.0.0.1:6379&gt; TFUNCTION LOAD REPLACE <span class="s2">"#!js api_version=1.0 name=myFirstLibrary\n redis.registerFunction('hello', ()=&gt;{ return 'Hello World updated'})"</span> </span></span><span class="line"><span class="cl">OK </span></span></code></pre> </div> <h2 id="uploading-an-external-file"> Uploading an external file </h2> <p> Use the <code> redis-cli </code> command to upload JavaScript from an external file. The file needs to contain the header, which contains the engine identifier, the API version, and the library name: <code> #!js api_version=1.0 name=myFirstLibrary </code> . </p> <div class="highlight"> <pre class="chroma"><code class="language-JavaScript" data-lang="JavaScript"><span class="line"><span class="cl"><span class="err">#</span><span class="o">!</span><span class="nx">js</span> <span class="nx">api_version</span><span class="o">=</span><span class="mf">1.0</span> <span class="nx">name</span><span class="o">=</span><span class="nx">lib</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="nx">redis</span><span class="p">.</span><span class="nx">registerFunction</span><span class="p">(</span><span class="s1">'hello'</span><span class="p">,</span> <span class="p">()=&gt;</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="k">return</span> <span class="s1">'Hello from an external file'</span> </span></span><span class="line"><span class="cl"><span class="p">})</span> </span></span></code></pre> </div> <p> Use the <code> redis-cli -x </code> option to send the file with the command and use the <code> TFUNCTION LOAD REPLACE </code> to replace the inline library with the one from the <code> main.js </code> file. </p> <div class="highlight"> <pre class="chroma"><code class="language-Shell" data-lang="Shell"><span class="line"><span class="cl">redis-cli -x TFUNCTION LOAD REPLACE &lt; ./main.js </span></span></code></pre> </div> <h2 id="creating-triggers"> Creating triggers </h2> <p> Functions within Redis can respond to events using keyspace triggers. While the majority of these events are initiated by command invocations, they also include events that occur when a key expires or is removed from the database. </p> <p> For the full list of supported events, please refer to the <a href="/docs/latest/develop/use/keyspace-notifications#events-generated-by-different-commands/?utm_source=redis&amp;utm_medium=app&amp;utm_campaign=redisinsight_triggers_and_functions_guide"> Redis keyspace notifications page </a> . </p> <p> The following code creates a new keyspace trigger that adds a new field to a new or updated hash with the latest update time. </p> <p> Load the code in your database: </p> <pre tabindex="0"><code class="language-redis" data-lang="redis">TFUNCTION LOAD REPLACE "#!js name=myFirstLibrary api_version=1.0\n function addLastUpdatedField(client, data) { if(data.event == 'hset') { var currentDateTime = Date.now(); client.call('hset', data.key, 'last_updated', currentDateTime.toString()); } } redis.registerKeySpaceTrigger('addLastUpdated', 'fellowship:', addLastUpdatedField);" // Register the KeySpaceTrigger 'AddLastUpdated' for keys with the prefix 'fellowship' with a callback to the function 'addLastUpdatedField' </code></pre> <p> Add a new hash with the required prefix to trigger our function. </p> <div class="highlight"> <pre class="chroma"><code class="language-Shell" data-lang="Shell"><span class="line"><span class="cl">127.0.0.1:6379&gt; HSET fellowship:1 name <span class="s2">"Frodo Baggins"</span> title <span class="s2">"The One Ring Bearer"</span> </span></span></code></pre> </div> <p> Check if the last updated time is added to the example. </p> <div class="highlight"> <pre class="chroma"><code class="language-Shell" data-lang="Shell"><span class="line"><span class="cl">127.0.0.1:6379&gt; HGETALL fellowship:1 </span></span><span class="line"><span class="cl">1<span class="o">)</span> <span class="s2">"name"</span> </span></span><span class="line"><span class="cl">2<span class="o">)</span> <span class="s2">"Frodo Baggins"</span> </span></span><span class="line"><span class="cl">3<span class="o">)</span> <span class="s2">"title"</span> </span></span><span class="line"><span class="cl">4<span class="o">)</span> <span class="s2">"The One Ring Bearer"</span> </span></span><span class="line"><span class="cl">5<span class="o">)</span> <span class="s2">"last_updated"</span> </span></span><span class="line"><span class="cl">6<span class="o">)</span> <span class="s2">"1693238681822"</span> </span></span></code></pre> </div> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/deprecated-features/triggers-and-functions/quick_start_cli/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/release-notes/rs-7-4-2-releases/rs-7-4-2-54/.html
<section class="prose w-full py-12 max-w-none"> <h1> Redis Enterprise Software release notes 7.4.2-54 (February 2024) </h1> <p class="text-lg -mt-5 mb-10"> New Cluster Manager UI enhancements, including Active-Active database management. Full TLS 1.3 support. Automatic recovery configuration. Full IPv6 support, including for internal traffic. Maintenance mode enhancements. Module management enhancements. RHEL 9 support. </p> <p> ​ <a href="https://redis.com/redis-enterprise-software/download-center/software/"> ​Redis Enterprise Software version 7.4.2 </a> is now available! </p> <h2 id="highlights"> Highlights </h2> <p> This version offers: </p> <ul> <li> <p> New Cluster Manager UI enhancements, including Active-Active database management </p> </li> <li> <p> Full TLS 1.3 support </p> </li> <li> <p> Automatic recovery configuration </p> </li> <li> <p> Full IPv6 support, including for internal traffic </p> </li> <li> <p> Maintenance mode enhancements </p> </li> <li> <p> Module management enhancements </p> </li> <li> <p> RHEL 7 and Oracle Linux 7, which were previously deprecated, are no longer supported </p> </li> <li> <p> RHEL 9 support </p> </li> </ul> <h2 id="new-in-this-release"> New in this release </h2> <h3 id="new-features"> New features </h3> <ul> <li> <p> Added full support for TLS 1.3: </p> <ul> <li> <p> TLS 1.3 cipher suites are now configurable for database connections. See <a href="/docs/latest/operate/rs/security/encryption/tls/ciphers/"> Configure cipher suites </a> for details. </p> </li> <li> <p> TLS 1.3 can be set as the minimum TLS version. See <a href="/docs/latest/operate/rs/security/encryption/tls/tls-protocols/"> Configure TLS protocol </a> for details. </p> </li> </ul> </li> <li> <p> Automatic recovery of databases from persistence files is configurable using the REST API. See <a href="/docs/latest/operate/rs/databases/recover/#configure-automatic-recovery"> Configure automatic recovery </a> for details. </p> </li> <li> <p> New clusters fully support IPv6, including for internal traffic. See <a href="/docs/latest/operate/rs/networking/multi-ip-ipv6/#enable-ipv6-for-internal-traffic"> Enable IPv6 for internal traffic </a> for details. </p> </li> </ul> <h3 id="enhancements"> Enhancements </h3> <ul> <li> <p> New Cluster Manager UI enhancements: </p> <ul> <li> <p> <a href="/docs/latest/operate/rs/databases/active-active/create/"> Create </a> and <a href="/docs/latest/operate/rs/databases/active-active/manage/"> manage </a> Active-Active databases. </p> </li> <li> <p> <a href="/docs/latest/operate/rs/databases/configure/db-defaults/"> Configure database defaults </a> : endpoint configuration, database proxy, and shards placement. </p> </li> <li> <p> Configure <a href="/docs/latest/operate/rs/security/encryption/tls/ciphers/#edit-ciphers-ui"> TLS cipher suites </a> and <a href="/docs/latest/operate/rs/security/encryption/tls/tls-protocols/#edit-tls-ui"> minimum TLS protocol </a> . </p> </li> <li> <p> Configure LDAP <a href="/docs/latest/operate/rs/security/access-control/ldap/enable-role-based-ldap/#authentication-timeout"> authentication timeout </a> . </p> </li> </ul> </li> <li> <p> <a href="/docs/latest/operate/rs/clusters/maintenance-mode/"> Maintenance mode </a> enhancements: </p> <ul> <li> <p> Only the latest maintenance mode snapshot is kept. </p> </li> <li> <p> Use the <code> overwrite_snapshot </code> option to create a new snapshot when you turn on maintenance mode. </p> </li> <li> <p> <code> keep_slave_shards </code> is deprecated. Use <code> evict_ha_replica </code> and <code> evict_active_active_replica </code> instead. </p> </li> <li> <p> View or delete node snapshots using <a href="/docs/latest/operate/rs/references/rest-api/requests/nodes/snapshots/"> <code> /v1/nodes/{node_uid}/snapshots </code> </a> REST API requests. </p> </li> </ul> </li> <li> <p> Added support for RHEL 9. </p> </li> <li> <p> Improved <code> actions </code> REST API: </p> <ul> <li> <p> Improved <code> progress </code> field returned by <a href="/docs/latest/operate/rs/references/rest-api/requests/actions/"> <code> GET /v1/actions </code> </a> requests. </p> </li> <li> <p> New request to get the status of all currently executing, pending, or completed actions for a specific database: <a href="/docs/latest/operate/rs/references/rest-api/requests/actions/bdb/"> <code> GET /v1/actions/bdb/&lt;bdb_uid&gt; </code> </a> </p> </li> </ul> </li> <li> <p> <a href="/docs/latest/operate/rs/references/rest-api/requests/users/#get-all-users"> <code> GET /v1/users </code> </a> REST API requests include a new <code> status </code> field in the response, which indicates whether the user can sign in: </p> <ul> <li> <p> <code> active </code> : user can sign in </p> </li> <li> <p> <code> locked </code> : user cannot sign in </p> </li> </ul> </li> <li> <p> Replaced the use of processes for <code> job_scheduler </code> , <code> cnm_http </code> , and <code> crdb_coordinator </code> with threads, which results in significant memory optimization. </p> </li> </ul> <h4 id="redis-module-feature-sets"> Redis module feature sets </h4> <p> Redis Enterprise comes packaged with several modules. As of version 7.4.2, Redis Enterprise includes two feature sets, compatible with different Redis database versions. </p> <p> Bundled Redis modules compatible with Redis database version 7.2: </p> <ul> <li> <p> <a href="https://github.com/RediSearch/RediSearch/releases/tag/v2.8.9"> RediSearch 2.8.9 </a> </p> </li> <li> <p> <a href="https://github.com/RedisJSON/RedisJSON/releases/tag/v2.6.8"> RedisJSON 2.6.8 </a> </p> </li> <li> <p> <a href="https://github.com/RedisTimeSeries/RedisTimeSeries/releases/tag/v1.10.9"> RedisTimeSeries 1.10.9 </a> </p> </li> <li> <p> <a href="https://github.com/RedisBloom/RedisBloom/releases/tag/v2.6.11"> RedisBloom 2.6.11 </a> </p> </li> <li> <p> <a href="https://github.com/RedisGears/RedisGears/releases/tag/v2.0.17-m18"> RedisGears 2.0.17 </a> </p> </li> </ul> <p> Bundled Redis modules compatible with Redis database versions 6.0 and 6.2: </p> <ul> <li> <p> <a href="https://github.com/RediSearch/RediSearch/releases/tag/v2.6.12"> RediSearch 2.6.12 </a> </p> </li> <li> <p> <a href="https://github.com/RedisJSON/RedisJSON/releases/tag/v2.4.7"> RedisJSON 2.4.7 </a> </p> </li> <li> <p> <a href="https://github.com/RedisTimeSeries/RedisTimeSeries/releases/tag/v1.8.11"> RedisTimeSeries 1.8.11 </a> </p> </li> <li> <p> <a href="https://github.com/RedisBloom/RedisBloom/releases/tag/v2.4.8"> RedisBloom 2.4.8 </a> </p> </li> <li> <p> <a href="https://github.com/RedisGraph/RedisGraph/releases/tag/v2.10.12"> RedisGraph v2.10.12 </a> </p> </li> </ul> <h3 id="resolved-issues"> Resolved issues </h3> <ul> <li> <p> RS57417: Azure OSS cluster with Private Link should no longer return public IPs in response to <code> CLUSTER </code> commands. </p> </li> <li> <p> RS106159: If RESP3 is not supported, <code> HELLO </code> requests now return an unknown command error instead of a protocol error. </p> </li> <li> <p> RS107538: Fixed an issue where DMC proxy perpetually restarted due to a CCS inconsistency. </p> </li> </ul> <h2 id="version-changes"> Version changes </h2> <h3 id="breaking-changes"> Breaking changes </h3> <ul> <li> <p> Renamed <code> sentinel_ssl_policy </code> field. The new name is <code> sentinel_tls_mode </code> . </p> <ul> <li> <p> You can only change the discovery service policy using <code> sentinel_tls_mode </code> . </p> </li> <li> <p> When retrieving the value of the current policy using <a href="/docs/latest/operate/rs/references/rest-api/requests/cluster/#get-cluster"> <code> GET /v1/cluster </code> </a> , both fields are returned for backward compatibility. </p> </li> </ul> </li> <li> <p> Port 3345 is now reserved for internal use. </p> </li> <li> <p> Type of <code> progress </code> field returned by <a href="/docs/latest/operate/rs/references/rest-api/requests/actions/"> <code> GET /v1/actions </code> </a> request modified from <code> integer </code> to <code> float </code> . </p> </li> </ul> <h3 id="deprecations"> Deprecations </h3> <h4 id="api-deprecations"> API deprecations </h4> <ul> <li> <p> The replica HA cluster policy is deprecated. </p> </li> <li> <p> The maintenance mode option <code> keep_slave_shards </code> is deprecated in <code> rladmin </code> and the REST API. Use <code> evict_ha_replica </code> and <code> evict_active_active_replica </code> instead. </p> </li> <li> <p> <code> /v1/debuginfo </code> REST API paths are deprecated. Use the new paths <a href="/docs/latest/operate/rs/references/rest-api/requests/cluster/debuginfo/"> <code> /v1/cluster/debuginfo </code> </a> , <a href="/docs/latest/operate/rs/references/rest-api/requests/nodes/debuginfo/"> <code> /v1/nodes/debuginfo </code> </a> , and <a href="/docs/latest/operate/rs/references/rest-api/requests/bdbs/debuginfo/"> <code> /v1/bdbs/debuginfo </code> </a> instead. </p> </li> </ul> <h4 id="legacy-ui-deprecation"> Legacy UI deprecation </h4> <p> The legacy UI is deprecated in favor of the new Cluster Manager UI and will be removed in a future release. </p> <h4 id="redis-60-database-deprecation"> Redis 6.0 database deprecation </h4> <p> Redis database version 6.0 is deprecated as of Redis Enterprise Software version 7.4.2 and will be removed in a future release. </p> <p> To prepare for the future removal of Redis 6.0: </p> <ul> <li> <p> For Redis Enterprise 6.2.* clusters, upgrade Redis 6.0 databases to Redis 6.2. See the <a href="https://raw.githubusercontent.com/redis/redis/6.2/00-RELEASENOTES"> Redis 6.2 release notes </a> for the list of changes. </p> </li> <li> <p> For Redis Enterprise 7.2.4 and 7.4.2 clusters, upgrade Redis 6.0 databases to Redis 7.2. Before you upgrade your databases, see the list of <a href="/docs/latest/operate/rs/release-notes/rs-7-2-4-releases/rs-7-2-4-52/#redis-72-breaking-changes"> Redis 7.2 breaking changes </a> and update any applications that connect to your database to handle these changes. </p> </li> </ul> <h4 id="operating-system-retirements"> Operating system retirements </h4> <ul> <li> RHEL 7 and Oracle Linux 7 were previously announced as deprecated in the <a href="/docs/latest/operate/rs/release-notes/rs-7-2-4-releases/#deprecations"> Redis Enterprise Software 7.2.4 release notes </a> . As of Redis Enterprise Software 7.4.2, RHEL 7 and Oracle Linux 7 are no longer supported. </li> </ul> <h4 id="security-retirements"> Security retirements </h4> <ul> <li> <p> The RC4 encryption cipher, which was previously deprecated in favor of stronger ciphers, is no longer supported. </p> </li> <li> <p> The 3DES encryption cipher, which was previously deprecated in favor of stronger ciphers like AES, is no longer supported. Verify that all clients, applications, and connections support the AES cipher. </p> </li> <li> <p> TLS 1.0 and TLS 1.1 connections, which were previously deprecated in favor of TLS 1.2 or later, are no longer supported. Verify that all clients, applications, and connections support TLS 1.2 or later. </p> </li> </ul> <h3 id="supported-platforms"> Supported platforms </h3> <p> The following table provides a snapshot of supported platforms as of this Redis Enterprise Software release. See the <a href="/docs/latest/operate/rs/references/supported-platforms/"> supported platforms reference </a> for more details about operating system compatibility. </p> <p> <span title="Check mark icon"> ✅ </span> Supported – The platform is supported for this version of Redis Enterprise Software. </p> <p> <span title="Warning icon"> ⚠️ </span> Deprecated – The platform is still supported for this version of Redis Enterprise Software, but support will be removed in a future release. </p> <p> <span title="X icon"> ❌ </span> End of life – Platform support ended in this version of Redis Enterprise Software. </p> <table> <thead> <tr> <th> Redis Enterprise </th> <th> 7.4.2 </th> <th> 7.2.4 </th> <th> 6.4.2 </th> <th> 6.2.18 </th> <th> 6.2.12 </th> <th> 6.2.10 </th> <th> 6.2.8 </th> <th> 6.2.4 </th> </tr> </thead> <tbody> <tr> <td> <strong> Release date </strong> </td> <td> Feb <br/> 2024 </td> <td> Aug <br/> 2023 </td> <td> Feb <br/> 2023 </td> <td> Sept <br/> 2022 </td> <td> Aug <br/> 2022 </td> <td> Feb <br/> 2022 </td> <td> Oct <br/> 2021 </td> <td> Aug <br/> 2021 </td> </tr> <tr> <td> <a href="/docs/latest/operate/rs/installing-upgrading/product-lifecycle/#endoflife-schedule"> <strong> End-of-life date </strong> </a> </td> <td> – </td> <td> July <br/> 2025 </td> <td> Feb <br/> 2025 </td> <td> Aug <br/> 2024 </td> <td> Aug <br/> 2024 </td> <td> Aug <br/> 2024 </td> <td> Aug <br/> 2024 </td> <td> Aug <br/> 2024 </td> </tr> <tr> <td> <strong> Ubuntu </strong> <sup> <a href="#table-note-1"> 1 </a> </sup> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> 20.04 </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> <sup> <a href="#table-note-6"> 6 </a> </sup> </td> <td> – </td> <td> – </td> <td> – </td> <td> – </td> <td> – </td> </tr> <tr> <td> 18.04 </td> <td> <span title="Deprecated"> ⚠️ </span> </td> <td> <span title="Deprecated"> ⚠️ </span> </td> <td> <span title="Supported"> <span title="Supported"> ✅ </span> </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> </tr> <tr> <td> 16.04 </td> <td> – </td> <td> <span title="End of life"> ❌ </span> </td> <td> <span title="Deprecated"> ⚠️ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> </tr> <tr> <td> <strong> RHEL &amp; CentOS </strong> <sup> <a href="#table-note-2"> 2 </a> </sup> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> 9.0-9.3 </td> <td> <span title="Supported"> ✅ </span> </td> <td> – </td> <td> – </td> <td> – </td> <td> – </td> <td> – </td> <td> – </td> <td> – </td> </tr> <tr> <td> 8.9 </td> <td> <span title="Supported"> ✅ </span> </td> <td> – </td> <td> – </td> <td> – </td> <td> – </td> <td> – </td> <td> – </td> <td> – </td> </tr> <tr> <td> 8.8 </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> <sup> <a href="#table-note-8"> 8 </a> </sup> </td> <td> – </td> <td> – </td> <td> – </td> <td> – </td> <td> – </td> </tr> <tr> <td> 8.7 </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> – </td> <td> – </td> <td> – </td> <td> – </td> <td> – </td> </tr> <tr> <td> 8.5-8.6 </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> – </td> <td> – </td> </tr> <tr> <td> 8.0-8.4 </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> – </td> </tr> <tr> <td> 7.0-7.9 </td> <td> <span title="End of life"> ❌ </span> </td> <td> <span title="Deprecated"> ⚠️ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> </tr> <tr> <td> <strong> Oracle Linux </strong> <sup> <a href="#table-note-3"> 3 </a> </sup> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> 8 </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> – </td> <td> – </td> </tr> <tr> <td> 7 </td> <td> <span title="End of life"> ❌ </span> </td> <td> <span title="Deprecated"> ⚠️ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> </tr> <tr> <td> <strong> Rocky Linux </strong> <sup> <a href="#table-note-3"> 3 </a> </sup> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> 8 </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> – </td> <td> – </td> <td> – </td> <td> – </td> </tr> <tr> <td> <strong> Amazon Linux </strong> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> 2 </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> <sup> <a href="#table-note-7"> 7 </a> </sup> </td> <td> – </td> <td> – </td> <td> – </td> <td> – </td> <td> – </td> </tr> <tr> <td> 1 </td> <td> <span title="Deprecated"> ⚠️ </span> </td> <td> <span title="Deprecated"> ⚠️ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> </tr> <tr> <td> <strong> Docker </strong> <sup> <a href="#table-note-4"> 4 </a> </sup> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> </tr> <tr> <td> <strong> Kubernetes </strong> <sup> <a href="#table-note-5"> 5 </a> </sup> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> <td> <span title="Supported"> ✅ </span> </td> </tr> </tbody> </table> <ol> <li> <p> <a name="table-note-1" style="display: block; height: 80px; margin-top: -80px;"> </a> The server version of Ubuntu is recommended for production installations. The desktop version is only recommended for development deployments. </p> </li> <li> <p> <a name="table-note-2" style="display: block; height: 80px; margin-top: -80px;"> </a> RHEL and CentOS deployments require <a href="/docs/latest/operate/rs/installing-upgrading/configuring/centos-rhel-firewall/"> firewall configuration </a> . </p> </li> <li> <p> <a name="table-note-3" style="display: block; height: 80px; margin-top: -80px;"> </a> Based on the corresponding RHEL version. </p> </li> <li> <p> <a name="table-note-4" style="display: block; height: 80px; margin-top: -80px;"> </a> <a href="/docs/latest/operate/rs/installing-upgrading/quickstarts/docker-quickstart/"> Docker images </a> of Redis Enterprise Software are certified for development and testing only. </p> </li> <li> <p> <a name="table-note-5" style="display: block; height: 80px; margin-top: -80px;"> </a> See the <a href="/docs/latest/operate/kubernetes/"> Redis Enterprise for Kubernetes documentation </a> . </p> </li> <li> <p> <a name="table-note-6" style="display: block; height: 80px; margin-top: -80px;"> </a> Ubuntu 20.04 support was added in Redis Enterprise Software <a href="/docs/latest/operate/rs/release-notes/rs-6-4-2-releases/rs-6-4-2-43/"> 6.4.2-43 </a> . </p> </li> <li> <p> <a name="table-note-7" style="display: block; height: 80px; margin-top: -80px;"> </a> A release candidate for Amazon Linux 2 support was added in Redis Enterprise Software <a href="/docs/latest/operate/rs/release-notes/rs-6-4-2-releases/rs-6-4-2-61/"> 6.4.2-61 </a> . Official support for Amazon Linux 2 was added in Redis Enterprise Software <a href="/docs/latest/operate/rs/release-notes/rs-6-4-2-releases/rs-6-4-2-69/"> 6.4.2-69 </a> . </p> </li> <li> <p> <a name="table-note-8" style="display: block; height: 80px; margin-top: -80px;"> </a> Redis Enterprise Software <a href="/docs/latest/operate/rs/release-notes/rs-6-4-2-releases/rs-6-4-2-103/"> 6.4.2-103 </a> and later supports RHEL 8.8. </p> </li> </ol> <h2 id="downloads"> Downloads </h2> <p> The following table shows the MD5 checksums for the available packages: </p> <table> <thead> <tr> <th> Package </th> <th> MD5 checksum (7.4.2-54 February release) </th> </tr> </thead> <tbody> <tr> <td> Ubuntu 18 </td> <td> d22100b9ce51f602b7b93751bc0ab439 </td> </tr> <tr> <td> Ubuntu 20 </td> <td> 784f3d07eafc99104da124d69f49b617 </td> </tr> <tr> <td> RedHat Enterprise Linux (RHEL) 8 <br/> Oracle Enterprise Linux (OL) 8 <br/> Rocky Enterprise Linux </td> <td> 107c1ce8510fd16026bac4179bb2aaa8 </td> </tr> <tr> <td> RedHat Enterprise Linux (RHEL) 9 </td> <td> d5fe1b085147b6ee1fc6f70aa43b263f </td> </tr> <tr> <td> Amazon Linux 2 </td> <td> 62b3dfb977750a3879c7e83c66a7726c </td> </tr> </tbody> </table> <h2 id="known-limitations"> Known limitations </h2> <h4 id="new-cluster-manager-ui-limitations"> New Cluster Manager UI limitations </h4> <p> The following legacy UI features are not yet available in the new Cluster Manager UI: </p> <ul> <li> <p> Remove a node. </p> <p> Use the REST API or legacy UI instead. See <a href="/docs/latest/operate/rs/clusters/remove-node/"> Remove a cluster node </a> for instructions. </p> </li> <li> <p> Purge an Active-Active instance. </p> <p> Use <a href="/docs/latest/operate/rs/references/cli-utilities/crdb-cli/crdb/purge-instance/"> <code> crdb-cli crdb purge-instance </code> </a> instead. </p> </li> <li> <p> Search and export the log. </p> </li> </ul> <h4 id="openssl-compatibility-issue-for-742-modules-on-amazon-linux-2"> OpenSSL compatibility issue for 7.4.2 modules on Amazon Linux 2 </h4> <p> Due to an OpenSSL 1.1 compatibility issue between modules and clusters, Redis Enterprise Software version 7.4.2-54 is not fully supported on Amazon Linux 2 clusters with databases that use the following modules: RedisGears, RediSearch, or RedisTimeSeries. </p> <p> This issue will be fixed in a future maintenance release. </p> <h4 id="redisgraph-prevents-upgrade-to-rhel-9"> RedisGraph prevents upgrade to RHEL 9 </h4> <p> You cannot upgrade from a prior RHEL version to RHEL 9 if the Redis Enterprise cluster contains a RedisGraph module, even if unused by any database. The <a href="https://redis.com/blog/redisgraph-eol/"> RedisGraph module has reached End-of-Life </a> and is completely unavailable in RHEL 9. </p> <h4 id="cannot-create-redis-v6x-active-active-databases-with-modules"> Cannot create Redis v6.x Active-Active databases with modules </h4> <p> You cannot create Active-Active databases that use Redis version 6.0 or 6.2 with modules. Databases that use Redis version 7.2 do not have this limitation. </p> <p> This limitation will be fixed in a future maintenance release. </p> <h2 id="security"> Security </h2> <h4 id="open-source-redis-security-fixes-compatibility"> Open source Redis security fixes compatibility </h4> <p> As part of Redis's commitment to security, Redis Enterprise Software implements the latest <a href="https://github.com/redis/redis/releases"> security fixes </a> available with <a href="https://github.com/redis/redis"> open source Redis </a> . Redis Enterprise has already included the fixes for the relevant CVEs. </p> <p> Some CVEs announced for open source Redis do not affect Redis Enterprise due to different or additional functionality available in Redis Enterprise that is not available in open source Redis. </p> <p> Redis Enterprise 7.4.2-54 supports open source Redis 7.2, 6.2, and 6.0. Below is the list of open source Redis CVEs fixed by version. </p> <p> Redis 7.2.x: </p> <ul> <li> <p> (CVE-2023-41056) In some cases, Redis may incorrectly handle resizing of memory buffers, which can result in incorrect accounting of buffer sizes and lead to heap overflow and potential remote code execution. </p> </li> <li> <p> (CVE-2023-41053) Redis does not correctly identify keys accessed by <code> SORT_RO </code> and, as a result, may grant users executing this command access to keys that are not explicitly authorized by the ACL configuration. (Redis 7.2.1) </p> </li> </ul> <p> Redis 7.0.x: </p> <ul> <li> <p> (CVE-2023-41056) In some cases, Redis may incorrectly handle resizing of memory buffers, which can result in incorrect accounting of buffer sizes and lead to heap overflow and potential remote code execution. </p> </li> <li> <p> (CVE-2023-41053) Redis does not correctly identify keys accessed by <code> SORT_RO </code> and, as a result, may grant users executing this command access to keys that are not explicitly authorized by the ACL configuration. (Redis 7.0.13) </p> </li> <li> <p> (CVE-2023-36824) Extracting key names from a command and a list of arguments may, in some cases, trigger a heap overflow and result in reading random heap memory, heap corruption, and potentially remote code execution. Specifically: using <code> COMMAND GETKEYS* </code> and validation of key names in ACL rules. (Redis 7.0.12) </p> </li> <li> <p> (CVE-2023-28856) Authenticated users can use the <code> HINCRBYFLOAT </code> command to create an invalid hash field that will crash Redis on access. (Redis 7.0.11) </p> </li> <li> <p> (CVE-2023-28425) Specially crafted <code> MSETNX </code> command can lead to assertion and denial-of-service. (Redis 7.0.10) </p> </li> <li> <p> (CVE-2023-25155) Specially crafted <code> SRANDMEMBER </code> , <code> ZRANDMEMBER </code> , and <code> HRANDFIELD </code> commands can trigger an integer overflow, resulting in a runtime assertion and termination of the Redis server process. (Redis 7.0.9) </p> </li> <li> <p> (CVE-2023-22458) Integer overflow in the Redis <code> HRANDFIELD </code> and <code> ZRANDMEMBER </code> commands can lead to denial-of-service. (Redis 7.0.8) </p> </li> <li> <p> (CVE-2022-36021) String matching commands (like <code> SCAN </code> or <code> KEYS </code> ) with a specially crafted pattern to trigger a denial-of-service attack on Redis, causing it to hang and consume 100% CPU time. (Redis 7.0.9) </p> </li> <li> <p> (CVE-2022-35977) Integer overflow in the Redis <code> SETRANGE </code> and <code> SORT </code> / <code> SORT_RO </code> commands can drive Redis to OOM panic. (Redis 7.0.8) </p> </li> <li> <p> (CVE-2022-35951) Executing an <code> XAUTOCLAIM </code> command on a stream key in a specific state, with a specially crafted <code> COUNT </code> argument, may cause an integer overflow, a subsequent heap overflow, and potentially lead to remote code execution. The problem affects Redis versions 7.0.0 or newer. (Redis 7.0.5) </p> </li> <li> <p> (CVE-2022-31144) A specially crafted <code> XAUTOCLAIM </code> command on a stream key in a specific state may result in heap overflow and potentially remote code execution. The problem affects Redis versions 7.0.0 or newer. (Redis 7.0.4) </p> </li> <li> <p> (CVE-2022-24834) A specially crafted Lua script executing in Redis can trigger a heap overflow in the cjson and cmsgpack libraries, and result in heap corruption and potentially remote code execution. The problem exists in all versions of Redis with Lua scripting support, starting from 2.6, and affects only authenticated and authorized users. (Redis 7.0.12) </p> </li> <li> <p> (CVE-2022-24736) An attacker attempting to load a specially crafted Lua script can cause NULL pointer dereference which will result in a crash of the <code> redis-server </code> process. This issue affects all versions of Redis. (Redis 7.0.0) </p> </li> <li> <p> (CVE-2022-24735) By exploiting weaknesses in the Lua script execution environment, an attacker with access to Redis can inject Lua code that will execute with the (potentially higher) privileges of another Redis user. (Redis 7.0.0) </p> </li> </ul> <p> Redis 6.2.x: </p> <ul> <li> <p> (CVE-2023-28856) Authenticated users can use the <code> HINCRBYFLOAT </code> command to create an invalid hash field that will crash Redis on access. (Redis 6.2.12) </p> </li> <li> <p> (CVE-2023-25155) Specially crafted <code> SRANDMEMBER </code> , <code> ZRANDMEMBER </code> , and <code> HRANDFIELD </code> commands can trigger an integer overflow, resulting in a runtime assertion and termination of the Redis server process. (Redis 6.2.11) </p> </li> <li> <p> (CVE-2023-22458) Integer overflow in the Redis <code> HRANDFIELD </code> and <code> ZRANDMEMBER </code> commands can lead to denial-of-service. (Redis 6.2.9) </p> </li> <li> <p> (CVE-2022-36021) String matching commands (like <code> SCAN </code> or <code> KEYS </code> ) with a specially crafted pattern to trigger a denial-of-service attack on Redis, causing it to hang and consume 100% CPU time. (Redis 6.2.11) </p> </li> <li> <p> (CVE-2022-35977) Integer overflow in the Redis <code> SETRANGE </code> and <code> SORT </code> / <code> SORT_RO </code> commands can drive Redis to OOM panic. (Redis 6.2.9) </p> </li> <li> <p> (CVE-2022-24834) A specially crafted Lua script executing in Redis can trigger a heap overflow in the cjson and cmsgpack libraries, and result in heap corruption and potentially remote code execution. The problem exists in all versions of Redis with Lua scripting support, starting from 2.6, and affects only authenticated and authorized users. (Redis 6.2.13) </p> </li> <li> <p> (CVE-2022-24736) An attacker attempting to load a specially crafted Lua script can cause NULL pointer dereference which will result in a crash of the <code> redis-server </code> process. This issue affects all versions of Redis. (Redis 6.2.7) </p> </li> <li> <p> (CVE-2022-24735) By exploiting weaknesses in the Lua script execution environment, an attacker with access to Redis can inject Lua code that will execute with the (potentially higher) privileges of another Redis user. (Redis 6.2.7) </p> </li> <li> <p> (CVE-2021-41099) Integer to heap buffer overflow handling certain string commands and network payloads, when <code> proto-max-bulk-len </code> is manually configured to a non-default, very large value. (Redis 6.2.6) </p> </li> <li> <p> (CVE-2021-32762) Integer to heap buffer overflow issue in <code> redis-cli </code> and <code> redis-sentinel </code> parsing large multi-bulk replies on some older and less common platforms. (Redis 6.2.6) </p> </li> <li> <p> (CVE-2021-32761) An integer overflow bug in Redis version 2.2 or newer can be exploited using the <code> BITFIELD </code> command to corrupt the heap and potentially result with remote code execution. (Redis 6.2.5) </p> </li> <li> <p> (CVE-2021-32687) Integer to heap buffer overflow with intsets, when <code> set-max-intset-entries </code> is manually configured to a non-default, very large value. (Redis 6.2.6) </p> </li> <li> <p> (CVE-2021-32675) Denial Of Service when processing RESP request payloads with a large number of elements on many connections. (Redis 6.2.6) </p> </li> <li> <p> (CVE-2021-32672) Random heap reading issue with Lua Debugger. (Redis 6.2.6) </p> </li> <li> <p> (CVE-2021-32628) Integer to heap buffer overflow handling ziplist-encoded data types, when configuring a large, non-default value for <code> hash-max-ziplist-entries </code> , <code> hash-max-ziplist-value </code> , <code> zset-max-ziplist-entries </code> or <code> zset-max-ziplist-value </code> . (Redis 6.2.6) </p> </li> <li> <p> (CVE-2021-32627) Integer to heap buffer overflow issue with streams, when configuring a non-default, large value for <code> proto-max-bulk-len </code> and <code> client-query-buffer-limit </code> . (Redis 6.2.6) </p> </li> <li> <p> (CVE-2021-32626) Specially crafted Lua scripts may result with Heap buffer overflow. (Redis 6.2.6) </p> </li> <li> <p> (CVE-2021-32625) An integer overflow bug in Redis version 6.0 or newer can be exploited using the STRALGO LCS command to corrupt the heap and potentially result with remote code execution. This is a result of an incomplete fix by CVE-2021-29477. (Redis 6.2.4) </p> </li> <li> <p> (CVE-2021-29478) An integer overflow bug in Redis 6.2 could be exploited to corrupt the heap and potentially result with remote code execution. The vulnerability involves changing the default set-max-intset-entries configuration value, creating a large set key that consists of integer values and using the COPY command to duplicate it. The integer overflow bug exists in all versions of Redis starting with 2.6, where it could result with a corrupted RDB or DUMP payload, but not exploited through COPY (which did not exist before 6.2). (Redis 6.2.3) </p> </li> <li> <p> (CVE-2021-29477) An integer overflow bug in Redis version 6.0 or newer could be exploited using the STRALGO LCS command to corrupt the heap and potentially result in remote code execution. The integer overflow bug exists in all versions of Redis starting with 6.0. (Redis 6.2.3) </p> </li> </ul> <p> Redis 6.0.x: </p> <ul> <li> <p> (CVE-2022-24834) A specially crafted Lua script executing in Redis can trigger a heap overflow in the cjson and cmsgpack libraries, and result in heap corruption and potentially remote code execution. The problem exists in all versions of Redis with Lua scripting support, starting from 2.6, and affects only authenticated and authorized users. (Redis 6.0.20) </p> </li> <li> <p> (CVE-2023-28856) Authenticated users can use the <code> HINCRBYFLOAT </code> command to create an invalid hash field that will crash Redis on access. (Redis 6.0.19) </p> </li> <li> <p> (CVE-2023-25155) Specially crafted <code> SRANDMEMBER </code> , <code> ZRANDMEMBER </code> , and <code> HRANDFIELD </code> commands can trigger an integer overflow, resulting in a runtime assertion and termination of the Redis server process. (Redis 6.0.18) </p> </li> <li> <p> (CVE-2022-36021) String matching commands (like <code> SCAN </code> or <code> KEYS </code> ) with a specially crafted pattern to trigger a denial-of-service attack on Redis, causing it to hang and consume 100% CPU time. (Redis 6.0.18) </p> </li> <li> <p> (CVE-2022-35977) Integer overflow in the Redis <code> SETRANGE </code> and <code> SORT </code> / <code> SORT_RO </code> commands can drive Redis to OOM panic. (Redis 6.0.17) </p> </li> </ul> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/release-notes/rs-7-4-2-releases/rs-7-4-2-54/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/7.4/references/cli-utilities/.html
<section class="prose w-full py-12 max-w-none"> <h1> Command-line utilities </h1> <p class="text-lg -mt-5 mb-10"> Reference for Redis Enterprise Software command-line utilities, including rladmin, redis-cli, crdb-cli, and rlcheck. </p> <p> Redis Enterprise Software includes a set of utilities to help you manage and test your cluster. To use a utility, run it from the command line. </p> <h2 id="public-utilities"> Public utilities </h2> <p> Administrators can use these CLI tools to manage and test a Redis Enterprise cluster. You can find the binaries in the <code> /opt/redislabs/bin/ </code> directory. </p> <table> <thead> <tr> <th style="text-align:left"> Utility </th> <th style="text-align:left"> Description </th> </tr> </thead> <tbody> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/7.4/references/cli-utilities/crdb-cli/"> crdb-cli (manage Active-Active) </a> </td> <td style="text-align:left"> Manage Active-Active databases. </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/7.4/references/cli-utilities/redis-cli/"> redis-cli (run Redis commands) </a> </td> <td style="text-align:left"> Run Redis commands. </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/7.4/references/cli-utilities/rladmin/"> rladmin (manage cluster) </a> </td> <td style="text-align:left"> Manage Redis Enterprise clusters and databases. </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/7.4/references/cli-utilities/rlcheck/"> rlcheck (verify nodes) </a> </td> <td style="text-align:left"> Verify nodes. </td> </tr> </tbody> </table> <h2 id="internal-utilities"> Internal utilities </h2> <p> The <code> /opt/redislabs/bin/ </code> directory also contains utilities used internally by Redis Enterprise Software and for troubleshooting. </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Warning: </div> Do not use these tools for normal operations. </div> </div> <table> <thead> <tr> <th> Utility </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> bdb-cli </td> <td> <code> redis-cli </code> connected to a database. </td> </tr> <tr> <td> ccs-cli </td> <td> Inspect Cluster Configuration Store. </td> </tr> <tr> <td> cnm-ctl </td> <td> Manages services for provisioning, migration, monitoring, <br/> resharding, rebalancing, deprovisioning, and autoscaling. </td> </tr> <tr> <td> consistency_checker </td> <td> Checks the consistency of Redis instances. </td> </tr> <tr> <td> crdbtop </td> <td> Monitor Active-Active databases. </td> </tr> <tr> <td> debug_mode </td> <td> Enables debug mode. </td> </tr> <tr> <td> debuginfo </td> <td> Collects cluster information. </td> </tr> <tr> <td> dmc-cli </td> <td> Configure and monitor the DMC proxy. </td> </tr> <tr> <td> pdns_control </td> <td> Sends commands to a running PowerDNS nameserver. </td> </tr> <tr> <td> redis_ctl </td> <td> Stops or starts Redis instances. </td> </tr> <tr> <td> rl_rdbloader </td> <td> Load RDB backup files to a server. </td> </tr> <tr> <td> rlutil </td> <td> Maintenance utility. </td> </tr> <tr> <td> shard-cli </td> <td> <code> redis-cli </code> connected to a shard. </td> </tr> <tr> <td> supervisorctl </td> <td> Manages the lifecycles of Redis Enterprise services. </td> </tr> </tbody> </table> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/references/cli-utilities/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/7.4/references/rest-api/objects/action/.html
<section class="prose w-full py-12 max-w-none"> <h1> Action object </h1> <p class="text-lg -mt-5 mb-10"> An object that represents cluster actions </p> <p> The cluster allows you to invoke general maintenance actions such as rebalancing or taking a node offline by moving all of its entities to other nodes. </p> <p> Actions are implemented as tasks in the cluster. Every task has a unique <code> task_id </code> assigned by the cluster, a task name which describes the task, a status, and additional task-specific parameters. </p> <p> The REST API provides a simplified interface that allows callers to invoke actions and query their status without a specific <code> task_id </code> . </p> <p> The action lifecycle is based on the following status and status transitions: </p> <a href="/docs/latest/images/rs/rest-api-action-cycle.png#no-click" sdata-lightbox="/images/rs/rest-api-action-cycle.png#no-click"> <img alt="Action lifecycle" src="/docs/latest/images/rs/rest-api-action-cycle.png#no-click"/> </a> <table> <thead> <tr> <th> Name </th> <th> Type/Value </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> progress </td> <td> float <nobr> (range: 0-100) </nobr> </td> <td> Represents percent completed (As of v7.4.2, the return value type changed to 'float' to provide improved progress indication) </td> </tr> <tr> <td> status </td> <td> queued </td> <td> Requested operation and added it to the queue to await processing </td> </tr> <tr> <td> </td> <td> starting </td> <td> Picked up operation from the queue and started processing </td> </tr> <tr> <td> </td> <td> running </td> <td> Currently executing operation </td> </tr> <tr> <td> </td> <td> cancelling </td> <td> Operation cancellation is in progress </td> </tr> <tr> <td> </td> <td> cancelled </td> <td> Operation cancelled </td> </tr> <tr> <td> </td> <td> completed </td> <td> Operation completed </td> </tr> <tr> <td> </td> <td> failed </td> <td> Operation failed </td> </tr> </tbody> </table> <p> When a task fails, the <code> error_code </code> and <code> error_message </code> fields describe the error. </p> <p> Possible <code> error_code </code> values: </p> <table> <thead> <tr> <th> Code </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> internal_error </td> <td> An internal error that cannot be mapped to a more precise error code </td> </tr> <tr> <td> insufficient_resources </td> <td> The cluster does not have sufficient resources to complete the required operation </td> </tr> </tbody> </table> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/references/rest-api/objects/action/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/redisce/.html
<section class="prose w-full py-12 max-w-none"> <h1> Redis Community Edition release notes </h1> <p class="text-lg -mt-5 mb-10"> Redis Community release notes for version 7.4 and later </p> <table> <thead> <tr> <th style="text-align:left"> Version (Release date) </th> <th style="text-align:left"> Major changes </th> </tr> </thead> <tbody> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/redisce/redisce-7.4-release-notes/"> v7.4.0 (July 2024) </a> </td> <td style="text-align:left"> Redis Community Edition 7.4 release notes. </td> </tr> </tbody> </table> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/redisce/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/hvals/.html
<section class="prose w-full py-12"> <h1 class="command-name"> HVALS </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">HVALS key</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available since: </dt> <dd class="m-0"> 2.0.0 </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(N) where N is the size of the hash. </dd> <dt class="font-semibold text-redis-ink-900 m-0"> ACL categories: </dt> <dd class="m-0"> <code> @read </code> <span class="mr-1 last:hidden"> , </span> <code> @hash </code> <span class="mr-1 last:hidden"> , </span> <code> @slow </code> <span class="mr-1 last:hidden"> , </span> </dd> </dl> <p> Returns all values in the hash stored at <code> key </code> . </p> <h2 id="examples"> Examples </h2> <div class="bg-slate-900 border-b border-slate-700 rounded-t-xl px-4 py-3 w-full flex"> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M2.5 10C2.5 5.85786 5.85786 2.5 10 2.5C14.1421 2.5 17.5 5.85786 17.5 10C17.5 14.1421 14.1421 17.5 10 17.5C5.85786 17.5 2.5 14.1421 2.5 10Z"> </path> </svg> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M10 2.5L18.6603 17.5L1.33975 17.5L10 2.5Z"> </path> </svg> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M10 2.5L12.0776 7.9322L17.886 8.22949L13.3617 11.8841L14.8738 17.5L10 14.3264L5.1262 17.5L6.63834 11.8841L2.11403 8.22949L7.92238 7.9322L10 2.5Z"> </path> </svg> </div> <form class="redis-cli overflow-y-auto max-h-80"> <pre tabindex="0">redis&gt; HSET myhash field1 "Hello" (integer) 1 redis&gt; HSET myhash field2 "World" (integer) 1 redis&gt; HVALS myhash 1) "Hello" 2) "World" </pre> <div class="prompt" style=""> <span> redis&gt; </span> <input autocomplete="off" name="prompt" spellcheck="false" type="text"/> </div> </form> <h2 id="resp2-reply"> RESP2 Reply </h2> <a href="../../develop/reference/protocol-spec#arrays"> Array reply </a> : a list of values in the hash, or an empty list when the key does not exist <h2 id="resp3-reply"> RESP3 Reply </h2> <a href="../../develop/reference/protocol-spec#arrays"> Array reply </a> : a list of values in the hash, or an empty list when the key does not exist. <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/hvals/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/7.4/references/rest-api/requests/bdbs/actions/export/.html
<section class="prose w-full py-12 max-w-none"> <h1> Export database action requests </h1> <p class="text-lg -mt-5 mb-10"> Export database requests </p> <table> <thead> <tr> <th> Method </th> <th> Path </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="#post-bdbs-actions-export"> POST </a> </td> <td> <code> /v1/bdbs/{uid}/actions/export </code> </td> <td> Initiate database export </td> </tr> </tbody> </table> <h2 id="post-bdbs-actions-export"> Initiate database export </h2> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">POST /v1/bdbs/<span class="o">{</span>int: uid<span class="o">}</span>/actions/export </span></span></code></pre> </div> <p> Initiate a database export. </p> <h3 id="permissions"> Permissions </h3> <table> <thead> <tr> <th> Permission name </th> <th> Roles </th> </tr> </thead> <tbody> <tr> <td> <a href="/docs/latest/operate/rs/7.4/references/rest-api/permissions/#start_bdb_export"> start_bdb_export </a> </td> <td> admin <br/> cluster_member <br/> db_member </td> </tr> </tbody> </table> <h3 id="post-request"> Request </h3> <h4 id="example-http-request"> Example HTTP request </h4> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">POST /bdbs/1/actions/export </span></span></code></pre> </div> <h4 id="headers"> Headers </h4> <table> <thead> <tr> <th> Key </th> <th> Value </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> Host </td> <td> cnm.cluster.fqdn </td> <td> Domain name </td> </tr> <tr> <td> Accept </td> <td> application/json </td> <td> Accepted media type </td> </tr> </tbody> </table> <h4 id="url-parameters"> URL parameters </h4> <table> <thead> <tr> <th> Field </th> <th> Type </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> uid </td> <td> integer </td> <td> The unique ID of the database </td> </tr> </tbody> </table> <h4 id="body"> Body </h4> <p> The request body should contain a JSON object with the following export parameters: </p> <table> <thead> <tr> <th> Field </th> <th> Type </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> export_location </td> <td> <a href="/docs/latest/operate/rs/7.4/references/rest-api/objects/bdb/backup_location/"> backup_location/export_location </a> object </td> <td> Details for the export destination. Call <a href="/docs/latest/operate/rs/7.4/references/rest-api/requests/jsonschema/#get-jsonschema"> <code> GET /jsonschema </code> </a> on the bdb object and review the <code> backup_location </code> field to retrieve the object's structure. </td> </tr> <tr> <td> email_notification </td> <td> boolean </td> <td> Enable/disable an email notification on export failure/ completion. (optional) </td> </tr> </tbody> </table> <h5 id="example-json-body"> Example JSON body </h5> <div class="highlight"> <pre class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"export_location"</span><span class="p">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"type"</span><span class="p">:</span> <span class="s2">"url"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"url"</span><span class="p">:</span> <span class="s2">"ftp://..."</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="nt">"email_notification"</span><span class="p">:</span> <span class="kc">true</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <p> The above request initiates an export operation to the specified location. </p> <h3 id="post-response"> Response </h3> <p> Returns a status code. </p> <h4 id="post-status-codes"> Status codes </h4> <table> <thead> <tr> <th> Code </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1"> 200 OK </a> </td> <td> The request is accepted and is being processed. In order to monitor progress, the BDB's <code> export_status </code> , <code> export_progress </code> , and <code> export_failure_reason </code> attributes can be consulted. </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5"> 404 Not Found </a> </td> <td> Attempting to perform an action on a nonexistent database. </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.7"> 406 Not Acceptable </a> </td> <td> Not all the modules loaded to the database support 'backup_restore' capability </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.10"> 409 Conflict </a> </td> <td> Database is currently busy with another action. In this context, this is a temporary condition and the request should be reattempted later. </td> </tr> </tbody> </table> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/references/rest-api/requests/bdbs/actions/export/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/7.4/references/rest-api/requests/crdbs/.html
<section class="prose w-full py-12 max-w-none"> <h1> CRDBs requests </h1> <p class="text-lg -mt-5 mb-10"> Active-Active database requests </p> <table> <thead> <tr> <th> Method </th> <th> Path </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="#get-all-crdbs"> GET </a> </td> <td> <code> /v1/crdbs </code> </td> <td> Get all Active-Active databases </td> </tr> <tr> <td> <a href="#get-crdb"> GET </a> </td> <td> <code> /v1/crdbs/{crdb_guid} </code> </td> <td> Get a specific Active-Active database </td> </tr> <tr> <td> <a href="#patch-crdbs"> PATCH </a> </td> <td> <code> /v1/crdbs/{crdb_guid} </code> </td> <td> Update an Active-Active database </td> </tr> <tr> <td> <a href="#post-crdb"> POST </a> </td> <td> <code> /v1/crdbs </code> </td> <td> Create a new Active-Active database </td> </tr> <tr> <td> <a href="#delete-crdb"> DELETE </a> </td> <td> <code> /v1/crdbs/{crdb_guid} </code> </td> <td> Delete an Active-Active database </td> </tr> </tbody> </table> <h2 id="get-all-crdbs"> Get all Active-Active databases </h2> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">GET /v1/crdbs </span></span></code></pre> </div> <p> Get a list of all Active-Active databases on the cluster. </p> <h3 id="get-all-request"> Request </h3> <h4 id="example-http-request"> Example HTTP request </h4> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">GET /crdbs </span></span></code></pre> </div> <h4 id="headers"> Headers </h4> <table> <thead> <tr> <th> Key </th> <th> Value </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> X-Task-ID </td> <td> string </td> <td> Specified task ID </td> </tr> <tr> <td> X-Result-TTL </td> <td> integer </td> <td> Time (in seconds) to keep task result </td> </tr> </tbody> </table> <h3 id="get-all-response"> Response </h3> <p> Returns a JSON array of <a href="/docs/latest/operate/rs/7.4/references/rest-api/objects/crdb/"> CRDB objects </a> . </p> <h5 id="get-all-status-codes"> Status codes </h5> <table> <thead> <tr> <th> Code </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1"> 200 OK </a> </td> <td> A list of Active-Active database. </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.2"> 401 Unauthorized </a> </td> <td> Unauthorized request. Invalid credentials </td> </tr> </tbody> </table> <h2 id="get-crdb"> Get an Active-Active database </h2> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">GET /v1/crdbs/<span class="o">{</span>crdb_guid<span class="o">}</span> </span></span></code></pre> </div> <p> Get a specific Active-Active database. </p> <h3 id="get-request"> Request </h3> <h4 id="example-http-request-1"> Example HTTP request </h4> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl"> GET /crdbs/552bbccb-99f3-4142-bd17-93d245f0bc79 </span></span></code></pre> </div> <h4 id="headers-1"> Headers </h4> <table> <thead> <tr> <th> Key </th> <th> Value </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> X-Task-ID </td> <td> string </td> <td> Specified task ID </td> </tr> <tr> <td> X-Result-TTL </td> <td> integer </td> <td> Time (in seconds) to keep task result </td> </tr> </tbody> </table> <h4 id="url-parameters"> URL parameters </h4> <table> <thead> <tr> <th> Field </th> <th> Type </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> crdb_guid </td> <td> string </td> <td> Globally unique Active-Active database ID (GUID) </td> </tr> </tbody> </table> <h4 id="query-parameters"> Query parameters </h4> <table> <thead> <tr> <th> Field </th> <th> Type </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> instance_id </td> <td> integer </td> <td> Instance from which to get the Active-Active database information </td> </tr> </tbody> </table> <h3 id="get-response"> Response </h3> <p> Returns a <a href="/docs/latest/operate/rs/7.4/references/rest-api/objects/crdb/"> CRDB object </a> . </p> <h4 id="get-status-codes"> Status codes </h4> <table> <thead> <tr> <th> Code </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1"> 200 OK </a> </td> <td> Active-Active database information is returned. </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.2"> 401 Unauthorized </a> </td> <td> Unauthorized request. Invalid credentials </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5"> 404 Not Found </a> </td> <td> Database or configuration does not exist. </td> </tr> </tbody> </table> <h2 id="patch-crdbs"> Update an Active-Active database </h2> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">PATCH /v1/crdbs/<span class="o">{</span>crdb_guid<span class="o">}</span> </span></span></code></pre> </div> <p> Update an Active-Active database's configuration. </p> <p> In order to add or remove instances, use <a href="/docs/latest/operate/rs/7.4/references/rest-api/requests/crdbs/updates/#post-crdbs-updates"> <nobr> <code> POST crdbs/{crdb_guid}/updates </code> </nobr> </a> instead. </p> <h3 id="patch-request"> Request </h3> <h4 id="example-http-request-2"> Example HTTP request </h4> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl"> PATCH /crdbs/552bbccb-99f3-4142-bd17-93d245f0bc79 </span></span></code></pre> </div> <h4 id="headers-2"> Headers </h4> <table> <thead> <tr> <th> Key </th> <th> Value </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> X-Task-ID </td> <td> string </td> <td> Specified task ID </td> </tr> <tr> <td> X-Result-TTL </td> <td> integer </td> <td> Time (in seconds) to keep task result </td> </tr> </tbody> </table> <h4 id="url-parameters-1"> URL parameters </h4> <table> <thead> <tr> <th> Field </th> <th> Type </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> crdb_guid </td> <td> string </td> <td> Globally unique Active-Active database ID (GUID) </td> </tr> </tbody> </table> <h4 id="request-body"> Request body </h4> <p> Include a <a href="/docs/latest/operate/rs/7.4/references/rest-api/objects/crdb/"> CRDB object </a> with updated fields in the request body. </p> <h3 id="patch-response"> Response </h3> <p> Returns a <a href="/docs/latest/operate/rs/7.4/references/rest-api/objects/crdb_task/"> CRDB task object </a> . </p> <h4 id="patch-status-codes"> Status codes </h4> <table> <thead> <tr> <th> Code </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1"> 200 OK </a> </td> <td> The request has been accepted. </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1"> 400 Bad Request </a> </td> <td> The posted Active-Active database contains invalid parameters. </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.2"> 401 Unauthorized </a> </td> <td> Unauthorized request. Invalid credentials </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5"> 404 Not Found </a> </td> <td> Configuration or Active-Active database not found. </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.7"> 406 Not Acceptable </a> </td> <td> The posted Active-Active database cannot be accepted. </td> </tr> </tbody> </table> <h2 id="post-crdb"> Create an Active-Active database </h2> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">POST /v1/crdbs </span></span></code></pre> </div> <p> Create a new Active-Active database. </p> <h3 id="post-request"> Request </h3> <h4 id="example-http-request-3"> Example HTTP request </h4> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl"> POST /crdbs </span></span></code></pre> </div> <h4 id="headers-3"> Headers </h4> <table> <thead> <tr> <th> Key </th> <th> Value </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> X-Task-ID </td> <td> string </td> <td> Specified task ID </td> </tr> <tr> <td> X-Result-TTL </td> <td> integer </td> <td> Time (in seconds) to keep task result </td> </tr> </tbody> </table> <h4 id="request-body-1"> Request body </h4> <p> Include a <a href="/docs/latest/operate/rs/7.4/references/rest-api/objects/crdb/"> CRDB object </a> , which defines the Active-Active database, in the request body. </p> <h5 id="example-body"> Example body </h5> <div class="highlight"> <pre class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"default_db_config"</span><span class="p">:</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"name"</span><span class="p">:</span> <span class="s2">"sample-crdb"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"memory_size"</span><span class="p">:</span> <span class="mi">214748365</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="nt">"instances"</span><span class="p">:</span> </span></span><span class="line"><span class="cl"> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"cluster"</span><span class="p">:</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"url"</span><span class="p">:</span> <span class="s2">"http://&lt;cluster1_FQDN&gt;:9443"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"credentials"</span><span class="p">:</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"username"</span><span class="p">:</span> <span class="s2">"&lt;username&gt;"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"password"</span><span class="p">:</span> <span class="s2">"&lt;password&gt;"</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="nt">"name"</span><span class="p">:</span> <span class="s2">"cluster-1"</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="nt">"compression"</span><span class="p">:</span> <span class="mi">6</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"cluster"</span><span class="p">:</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"url"</span><span class="p">:</span> <span class="s2">"http://&lt;cluster2_FQDN&gt;:9443"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"credentials"</span><span class="p">:</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"username"</span><span class="p">:</span> <span class="s2">"&lt;username&gt;"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"password"</span><span class="p">:</span> <span class="s2">"&lt;password&gt;"</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="nt">"name"</span><span class="p">:</span> <span class="s2">"cluster-2"</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="nt">"compression"</span><span class="p">:</span> <span class="mi">6</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="nt">"name"</span><span class="p">:</span> <span class="s2">"sample-crdb"</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <p> This JSON body creates an Active-Active database without TLS and with two participating clusters. </p> <h3 id="post-response"> Response </h3> <p> Returns a <a href="/docs/latest/operate/rs/7.4/references/rest-api/objects/crdb_task/"> CRDB task object </a> . </p> <h4 id="post-status-codes"> Status codes </h4> <table> <thead> <tr> <th> Code </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1"> 200 OK </a> </td> <td> The request has been accepted. </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1"> 400 Bad Request </a> </td> <td> The request is invalid or malformed. </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.2"> 401 Unauthorized </a> </td> <td> Unauthorized request. Invalid credentials </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.7"> 406 Not Acceptable </a> </td> <td> The posted Active-Active database cannot be accepted. </td> </tr> </tbody> </table> <h2 id="delete-crdb"> Delete an Active-Active database </h2> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">DELETE /v1/crdbs/<span class="o">{</span>crdb_guid<span class="o">}</span> </span></span></code></pre> </div> <p> Delete an Active-Active database. </p> <h3 id="delete-request"> Request </h3> <h4 id="example-http-request-4"> Example HTTP request </h4> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl"> DELETE /crdbs/552bbccb-99f3-4142-bd17-93d245f0bc79 </span></span></code></pre> </div> <h4 id="headers-4"> Headers </h4> <table> <thead> <tr> <th> Key </th> <th> Value </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> X-Task-ID </td> <td> string </td> <td> Specified task ID </td> </tr> <tr> <td> X-Result-TTL </td> <td> integer </td> <td> Time (in seconds) to keep task result </td> </tr> </tbody> </table> <h4 id="url-parameters-2"> URL parameters </h4> <table> <thead> <tr> <th> Field </th> <th> Type </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> crdb_guid </td> <td> string </td> <td> Globally unique Active-Active database ID (GUID) </td> </tr> </tbody> </table> <h3 id="delete-response"> Response </h3> <p> Returns a <a href="/docs/latest/operate/rs/7.4/references/rest-api/objects/crdb_task/"> CRDB task object </a> . </p> <h4 id="delete-status-codes"> Status codes </h4> <table> <thead> <tr> <th> Code </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1"> 200 OK </a> </td> <td> Action was successful. </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.2"> 401 Unauthorized </a> </td> <td> Unauthorized request. Invalid credentials </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5"> 404 Not Found </a> </td> <td> Configuration or Active-Active database not found. </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.7"> 406 Not Acceptable </a> </td> <td> The Active-Active GUID is invalid or the Active-Active database was already deleted. </td> </tr> </tbody> </table> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/references/rest-api/requests/crdbs/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/references/rest-api/objects/statistics/.html
<section class="prose w-full py-12 max-w-none"> <h1> Statistics </h1> <p class="text-lg -mt-5 mb-10"> An object that contains metrics for clusters, databases, nodes, or shards </p> <h2 id="statistics-overview"> Statistics overview </h2> <p> Clusters, databases, nodes, and shards collect various statistics at regular time intervals. View the statistics for these objects using <code> GET stats </code> requests to their respective endpoints: </p> <ul> <li> <a href="/docs/latest/operate/rs/references/rest-api/requests/cluster/stats/"> Cluster stats </a> </li> <li> <a href="/docs/latest/operate/rs/references/rest-api/requests/bdbs/stats/"> Database stats </a> </li> <li> <a href="/docs/latest/operate/rs/references/rest-api/requests/nodes/stats/"> Node stats </a> </li> <li> <a href="/docs/latest/operate/rs/references/rest-api/requests/shards/stats/"> Shard stats </a> </li> </ul> <p> View endpoint stats using <code> GET </code> requests, see: </p> <ul> <li> <a href="/docs/latest/operate/rs/references/rest-api/requests/endpoints-stats/"> Endpoint stats </a> </li> </ul> <h3 id="response-object"> Response object </h3> <p> Statistics returned from API requests always contain the following fields: </p> <ul> <li> <code> interval </code> : a string that represents the statistics time interval. Valid values include: <ul> <li> 1sec </li> <li> 10sec </li> <li> 5min </li> <li> 15min </li> <li> 1hour </li> <li> 12hour </li> <li> 1week </li> </ul> </li> <li> <code> stime </code> : a timestamp that represents the beginning of the interval, in the format "2015-05-27T12:00:00Z" </li> <li> <code> etime </code> : a timestamp that represents the end of the interval, in the format "2015-05-27T12:00:00Z" </li> </ul> <p> The statistics returned by the API also contain fields that represent the values of different metrics for an object during the specified time interval. </p> <p> More details about the metrics relevant to each object: </p> <ul> <li> <a href="/docs/latest/operate/rs/references/rest-api/objects/statistics/cluster-metrics/"> Cluster metrics </a> </li> <li> <a href="/docs/latest/operate/rs/references/rest-api/objects/statistics/db-metrics/"> DB metrics </a> </li> <li> <a href="/docs/latest/operate/rs/references/rest-api/objects/statistics/node-metrics/"> Node metrics </a> </li> <li> <a href="/docs/latest/operate/rs/references/rest-api/objects/statistics/shard-metrics/"> Shard metrics </a> </li> </ul> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> Certain statistics are not documented because they are for internal use only and should be ignored. Some statistics will only appear in API responses when they are relevant. </div> </div> <h3 id="optional-url-parameters"> Optional URL parameters </h3> <p> There are several optional URL parameters you can pass to the various <code> GET stats </code> requests to filter the returned statistics. </p> <ul> <li> <code> stime </code> : limit the start of the time range of the returned statistics </li> <li> <code> etime </code> : limit the end of the time range of the returned statistics </li> <li> <code> metrics </code> : only return the statistics for the specified metrics (comma-separated list) </li> </ul> <h2 id="maximum-number-of-samples-per-interval"> Maximum number of samples per interval </h2> <p> The system retains a maximum number of most recent samples for each interval. </p> <table> <thead> <tr> <th> Interval </th> <th> Max samples </th> </tr> </thead> <tbody> <tr> <td> 1sec </td> <td> 10 </td> </tr> <tr> <td> 10sec </td> <td> 30 </td> </tr> <tr> <td> 5min </td> <td> 12 </td> </tr> <tr> <td> 15min </td> <td> 96 </td> </tr> <tr> <td> 1hour </td> <td> 168 </td> </tr> <tr> <td> 12hour </td> <td> 62 </td> </tr> <tr> <td> 1week </td> <td> 53 </td> </tr> </tbody> </table> <p> The actual number of samples returned by a <code> GET stats </code> request depends on how many samples are available and any filters applied by the optional URL parameters. For example, newly created objects (clusters, nodes, databases, or shards) or a narrow time filter range will return fewer samples. </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> To reduce load generated by stats collection, relatively inactive databases or shards (less than 5 ops/sec) do not collect 1sec stats at one second intervals. Instead, they collect 1sec stats every 2-5 seconds but still retain the same maximum number of samples. </div> </div> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/references/rest-api/objects/statistics/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/7.4/references/rest-api/requests/cluster/.html
<section class="prose w-full py-12 max-w-none"> <h1> Cluster requests </h1> <p class="text-lg -mt-5 mb-10"> Cluster settings requests </p> <table> <thead> <tr> <th> Method </th> <th> Path </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="#get-cluster"> GET </a> </td> <td> <code> /v1/cluster </code> </td> <td> Get cluster info </td> </tr> <tr> <td> <a href="#put-cluster"> PUT </a> </td> <td> <code> /v1/cluster </code> </td> <td> Update cluster settings </td> </tr> </tbody> </table> <h2 id="get-cluster"> Get cluster info </h2> <pre><code>GET /v1/cluster </code></pre> <p> Get cluster info. </p> <h4 id="required-permissions"> Required permissions </h4> <table> <thead> <tr> <th> Permission name </th> </tr> </thead> <tbody> <tr> <td> <a href="/docs/latest/operate/rs/7.4/references/rest-api/permissions/#view_cluster_info"> view_cluster_info </a> </td> </tr> </tbody> </table> <h3 id="get-request"> Request </h3> <h4 id="example-http-request"> Example HTTP request </h4> <pre><code>GET /cluster </code></pre> <h4 id="request-headers"> Request headers </h4> <table> <thead> <tr> <th> Key </th> <th> Value </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> Host </td> <td> cnm.cluster.fqdn </td> <td> Domain name </td> </tr> <tr> <td> Accept </td> <td> application/json </td> <td> Accepted media type </td> </tr> </tbody> </table> <h3 id="get-response"> Response </h3> <p> Returns a <a href="/docs/latest/operate/rs/7.4/references/rest-api/objects/cluster/"> cluster object </a> . </p> <h4 id="example-json-body"> Example JSON body </h4> <div class="highlight"> <pre class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"name"</span><span class="p">:</span> <span class="s2">"my-rlec-cluster"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"alert_settings"</span><span class="p">:</span> <span class="p">{</span> <span class="nt">"..."</span> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="nt">"created_time"</span><span class="p">:</span> <span class="s2">"2015-04-29T09:09:25Z"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"email_alerts"</span><span class="p">:</span> <span class="kc">false</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"email_from"</span><span class="p">:</span> <span class="s2">""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"rack_aware"</span><span class="p">:</span> <span class="kc">false</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"smtp_host"</span><span class="p">:</span> <span class="s2">""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"smtp_password"</span><span class="p">:</span> <span class="s2">""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"smtp_port"</span><span class="p">:</span> <span class="mi">25</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"smtp_tls_mode"</span><span class="p">:</span> <span class="s2">"none"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"smtp_username"</span><span class="p">:</span> <span class="s2">""</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <h3 id="get-status-codes"> Status codes </h3> <table> <thead> <tr> <th> Code </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1"> 200 OK </a> </td> <td> No error </td> </tr> </tbody> </table> <h2 id="put-cluster"> Update cluster settings </h2> <pre><code>PUT /v1/cluster </code></pre> <p> Update cluster settings. </p> <p> If called with the <code> dry_run </code> URL query string, the function will validate the <a href="/docs/latest/operate/rs/7.4/references/rest-api/objects/cluster/"> cluster object </a> , but will not apply the requested changes. </p> <h4 id="required-permissions-1"> Required permissions </h4> <table> <thead> <tr> <th> Permission name </th> </tr> </thead> <tbody> <tr> <td> <a href="/docs/latest/operate/rs/7.4/references/rest-api/permissions/#update_cluster"> update_cluster </a> </td> </tr> </tbody> </table> <h3 id="put-request"> Request </h3> <h4 id="example-http-request-1"> Example HTTP request </h4> <pre><code>PUT /cluster </code></pre> <h4 id="example-json-body-1"> Example JSON body </h4> <div class="highlight"> <pre class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"email_alerts"</span><span class="p">:</span> <span class="kc">true</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"alert_settings"</span><span class="p">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"node_failed"</span><span class="p">:</span> <span class="kc">true</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"node_memory"</span><span class="p">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"enabled"</span><span class="p">:</span> <span class="kc">true</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"threshold"</span><span class="p">:</span> <span class="s2">"80"</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <p> The above request will enable email alerts and alert reporting for node failures and node removals. </p> <h4 id="request-headers-1"> Request headers </h4> <table> <thead> <tr> <th> Key </th> <th> Value </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> Host </td> <td> cnm.cluster.fqdn </td> <td> Domain name </td> </tr> <tr> <td> Accept </td> <td> application/json </td> <td> Accepted media type </td> </tr> </tbody> </table> <h4 id="url-parameters"> URL parameters </h4> <table> <thead> <tr> <th> Field </th> <th> Type </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> dry_run </td> <td> string </td> <td> Validate but don't apply the new cluster settings </td> </tr> </tbody> </table> <h4 id="request-body"> Request body </h4> <p> Include a <a href="/docs/latest/operate/rs/7.4/references/rest-api/objects/cluster/"> cluster object </a> with updated fields in the request body. </p> <h3 id="put-response"> Response </h3> <h4 id="example-json-body-2"> Example JSON body </h4> <div class="highlight"> <pre class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"name"</span><span class="p">:</span> <span class="s2">"mycluster.mydomain.com"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"email_alerts"</span><span class="p">:</span> <span class="kc">true</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"alert_settings"</span><span class="p">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"node_failed"</span><span class="p">:</span> <span class="kc">true</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"node_memory"</span><span class="p">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"enabled"</span><span class="p">:</span> <span class="kc">true</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"threshold"</span><span class="p">:</span> <span class="s2">"80"</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="nt">"// additional fields..."</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <h3 id="put-error-codes"> Error codes </h3> <p> When errors are reported, the server may return a JSON object with <code> error_code </code> and <code> message </code> field that provide additional information. The following are possible <code> error_code </code> values: </p> <table> <thead> <tr> <th> Code </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> bad_nginx_conf </td> <td> • Designated port is already bound. <br/> <br/> • nginx configuration is illegal. </td> </tr> <tr> <td> bad_debuginfo_path </td> <td> • Debuginfo path doesn't exist. <br/> <br/> • Debuginfo path is inaccessible. </td> </tr> <tr> <td> config_edit_conflict </td> <td> Cluster config was edited by another source simultaneously. </td> </tr> </tbody> </table> <h3 id="put-status-codes"> Status codes </h3> <table> <thead> <tr> <th> Code </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1"> 200 OK </a> </td> <td> No error. </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1"> 400 Bad Request </a> </td> <td> Bad content provided. </td> </tr> </tbody> </table> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/references/rest-api/requests/cluster/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/develop/interact/search-and-query/basic-constructs/field-and-type-options/.html
<section class="prose w-full py-12"> <h1> Field and type options </h1> <p class="text-lg -mt-5 mb-10"> Available field types and options. </p> <p> Redis Stack provides various field types that allow you to store and search different kinds of data in your indexes. This page explains the available field types, their characteristics, and how they can be used effectively. </p> <h2 id="numeric-fields"> Numeric fields </h2> <p> Numeric fields are used to store non-textual, countable values. They can hold integer or floating-point values. Numeric fields are sortable, meaning you can perform range-based queries and retrieve documents based on specific numeric conditions. For example, you can search for documents with a price between a certain range or retrieve documents with a specific rating value. </p> <p> You can add number fields to a schema in <a href="/docs/latest/commands/ft.create/"> <code> FT.CREATE </code> </a> using this syntax: </p> <pre tabindex="0"><code>FT.CREATE ... SCHEMA ... {field_name} NUMERIC [SORTABLE] [NOINDEX] </code></pre> <p> where: </p> <ul> <li> <code> SORTABLE </code> indicates that the field can be sorted. This is useful for performing range queries and sorting search results based on numeric values. </li> <li> <code> NOINDEX </code> indicates that the field is not indexed. This is useful for storing numeric values that you don't want to search for, but that you want to retrieve in search results. </li> </ul> <p> You can search for documents with specific numeric values using the <code> @&lt;field_name&gt;:[&lt;min&gt; &lt;max&gt;] </code> query syntax. For example, this query finds documents with a price between 200 and 300: </p> <pre tabindex="0"><code>FT.SEARCH products "@price:[200 300]" </code></pre> <p> You can also use the following query syntax to perform more complex numeric queries: </p> <table> <thead> <tr> <th> <strong> Comparison operator </strong> </th> <th> <strong> Query string </strong> </th> <th> <strong> Comment </strong> </th> </tr> </thead> <tbody> <tr> <td> min &lt;= x &lt;= max </td> <td> @field:[min max] </td> <td> Fully inclusive range </td> </tr> <tr> <td> </td> <td> "@field&gt;=min @field&lt;=max" </td> <td> Fully inclusive range * </td> </tr> <tr> <td> min &lt; x &lt; max </td> <td> @field:[(min (max] </td> <td> Fully exclusive range </td> </tr> <tr> <td> </td> <td> "@field&gt;min @field&lt;max" </td> <td> Fully exclusive range * </td> </tr> <tr> <td> </td> <td> </td> <td> grouping with a space denotes AND relationship </td> </tr> <tr> <td> x &gt;= min </td> <td> @field:[min +inf] </td> <td> Upper open range </td> </tr> <tr> <td> </td> <td> @field&gt;=min </td> <td> Upper open range * </td> </tr> <tr> <td> x &lt;= max </td> <td> @field:[-inf max] </td> <td> Lower open range </td> </tr> <tr> <td> </td> <td> @field&lt;=max </td> <td> Lower open range * </td> </tr> <tr> <td> x == val </td> <td> @field:[val val] </td> <td> Equal </td> </tr> <tr> <td> </td> <td> @field:[val] </td> <td> Equal * </td> </tr> <tr> <td> </td> <td> @field==val </td> <td> Equal * </td> </tr> <tr> <td> x != val </td> <td> -@field:[val val] </td> <td> Not equal </td> </tr> <tr> <td> </td> <td> @field!=val </td> <td> Not equal * </td> </tr> <tr> <td> x == val1 or x == val2 </td> <td> "@field==val1 | @field==val2" </td> <td> Grouping with a bar denotes OR relationship * </td> </tr> </tbody> </table> <p> * New syntax as of RediSearch v2.10. Requires <a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/dialects/#dialect-2"> <code> DIALECT 2 </code> </a> . </p> <h2 id="geo-fields"> Geo fields </h2> <p> Geo fields are used to store geographical coordinates such as longitude and latitude. They enable geospatial radius queries, which allow you to implement location-based search functionality in your applications such as finding nearby restaurants, stores, or any other points of interest. </p> <p> You can add geo fields to the schema in <a href="/docs/latest/commands/ft.create/"> <code> FT.CREATE </code> </a> using this syntax: </p> <pre tabindex="0"><code>FT.CREATE ... SCHEMA ... {field_name} GEO [SORTABLE] [NOINDEX] </code></pre> <p> Where: </p> <ul> <li> <code> SORTABLE </code> indicates that the field can be sorted. This is useful for performing range queries and sorting search results based on coordinates. </li> <li> <code> NOINDEX </code> indicates that the field is not indexed. This is useful for storing coordinates that you don't want to search for, but that you still want to retrieve in search results. </li> </ul> <p> You can query geo fields using the <code> @&lt;field_name&gt;:[&lt;lon&gt; &lt;lat&gt; &lt;radius&gt; &lt;unit&gt;] </code> query syntax. For example, this query finds documents within 1000 kilometers from the point <code> 2.34, 48.86 </code> : </p> <pre tabindex="0"><code>FT.SEARCH cities "@coords:[2.34 48.86 1000 km]" </code></pre> <h2 id="vector-fields"> Vector fields </h2> <p> Vector fields are floating-point vectors that are typically generated by external machine learning models. These vectors represent unstructured data such as text, images, or other complex features. Redis Stack allows you to search for similar vectors using vector search algorithms like cosine similarity, Euclidean distance, and inner product. This enables you to build advanced search applications, recommendation systems, or content similarity analysis. </p> <p> You can add vector fields to the schema in <a href="/docs/latest/commands/ft.create/"> <code> FT.CREATE </code> </a> using this syntax: </p> <pre tabindex="0"><code>FT.CREATE ... SCHEMA ... {field_name} VECTOR {algorithm} {count} [{attribute_name} {attribute_value} ...] </code></pre> <p> Where: </p> <ul> <li> <p> <code> {algorithm} </code> must be specified and be a supported vector similarity index algorithm. The supported algorithms are: </p> <ul> <li> <code> FLAT </code> : brute force algorithm. </li> <li> <code> HNSW </code> : hierarchical, navigable, small world algorithm. </li> </ul> <p> The <code> {algorithm} </code> attribute specifies the algorithm to use when searching <code> k </code> most similar vectors in the index or filtering vectors by range. </p> </li> <li> <p> <code> {count} </code> specifies the number of attributes for the index and it must be present. Notice that <code> {count} </code> represents the total number of attribute pairs passed in the command. Algorithm parameters should be submitted as named arguments. </p> <p> For example: </p> <pre tabindex="0"><code>FT.CREATE my_idx SCHEMA vec_field VECTOR FLAT 6 TYPE FLOAT32 DIM 128 DISTANCE_METRIC L2 </code></pre> <p> Here, three parameters are passed for the index ( <a href="/docs/latest/commands/type/"> <code> TYPE </code> </a> , <code> DIM </code> , <code> DISTANCE_METRIC </code> ), and <code> count </code> is the total number of attributes (6). </p> </li> <li> <p> <code> {attribute_name} {attribute_value} </code> are algorithm attributes for the creation of the vector index. Every algorithm has its own mandatory and optional attributes. </p> </li> </ul> <p> For more information about vector fields, see <a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/vectors/"> vector fields </a> . </p> <h2 id="tag-fields"> Tag fields </h2> <p> Tag fields are used to store textual data that represents a collection of data tags or labels. Tag fields are characterized by their low cardinality, meaning they typically have a limited number of distinct values. Unlike text fields, tag fields are stored as-is without tokenization or stemming. They are useful for organizing and categorizing data, making it easier to filter and retrieve documents based on specific tags. </p> <p> Tag fields can be added to the schema with the following syntax: </p> <pre tabindex="0"><code>FT.CREATE ... SCHEMA ... {field_name} TAG [SEPARATOR {sep}] [CASESENSITIVE] </code></pre> <p> where </p> <ul> <li> <p> <code> SEPARATOR </code> defaults to a comma ( <code> , </code> ), and can be any printable ASCII character. It is used to separate tags in the field value. For example, if the field value is <code> hello,world </code> , the tags are <code> hello </code> and <code> world </code> . </p> </li> <li> <p> <code> CASESENSITIVE </code> indicates that the field is case-sensitive. By default, tag fields are case-insensitive. </p> </li> </ul> <p> You can search for documents with specific tags using the <code> @&lt;field_name&gt;:{&lt;tag&gt;} </code> query syntax. For example, this query finds documents with the tag <code> blue </code> : </p> <pre tabindex="0"><code>FT.SEARCH idx "@tags:{blue}" </code></pre> <p> For more information about tag fields, see <a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/tags/"> Tag Fields </a> . </p> <h2 id="text-fields"> Text fields </h2> <p> Text fields are specifically designed for storing human language text. When indexing text fields, Redis Stack performs several transformations to optimize search capabilities. The text is transformed to lowercase, allowing case-insensitive searches. The data is tokenized, meaning it is split into individual words or tokens, which enables efficient full-text search functionality. Text fields can be weighted to assign different levels of importance to specific fields during search operations. Additionally, text fields can be sorted based on their values, enabling the sorting of search results by relevance or other criteria. </p> <p> Text fields can be added to the schema with the following syntax: </p> <pre tabindex="0"><code>FT.CREATE ... SCHEMA ... {field_name} TEXT [WEIGHT] [NOSTEM] [PHONETIC {matcher}] [SORTABLE] [NOINDEX] [WITHSUFFIXTRIE] </code></pre> <p> where </p> <ul> <li> <p> <code> WEIGHT </code> indicates that the field is weighted. This is useful for assigning different levels of importance to specific fields during search operations. </p> </li> <li> <p> <code> NOSTEM </code> indicates that the field is not stemmed. This is useful for storing text that you don't want to be tokenized, such as URLs or email addresses. </p> </li> <li> <p> <code> PHONETIC {matcher} </code> Declaring a text attribute as <code> PHONETIC </code> will perform phonetic matching on it in searches by default. The obligatory matcher argument specifies the phonetic algorithm and language used. The following matchers are supported: </p> <ul> <li> <code> dm:en </code> - double metaphone for English </li> <li> <code> dm:fr </code> - double metaphone for French </li> <li> <code> dm:pt </code> - double metaphone for Portuguese </li> <li> <code> dm:es </code> - double metaphone for Spanish </li> </ul> <p> For more information, see <a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/phonetic_matching/"> Phonetic Matching </a> . </p> </li> <li> <p> <code> SORTABLE </code> indicates that the field can be sorted. This is useful for performing range queries and sorting search results based on text values. </p> </li> <li> <p> <code> NOINDEX </code> indicates that the field is not indexed. This is useful for storing text that you don't want to search for, but that you still want to retrieve in search results. </p> </li> <li> <p> <code> WITHSUFFIXTRIE </code> indicates that the field will be indexed with a suffix trie. The index will keep a suffix trie with all terms which match the suffix. It is used to optimize <code> contains (*foo*) </code> and <code> suffix (*foo) </code> queries. Otherwise, a brute-force search on the trie is performed. If a suffix trie exists for some fields, these queries will be disabled for other fields. </p> </li> </ul> <p> You can search for documents with specific text values using the <code> &lt;term&gt; </code> or the <code> @&lt;field_name&gt;:{&lt;term&gt;} </code> query syntax. Here are a couple of examples: </p> <ul> <li> <p> Search for a term in every text attribute: </p> <pre tabindex="0"><code>FT.SEARCH books-idx "wizard" </code></pre> </li> <li> <p> Search for a term only in the <code> title </code> attribute </p> <pre tabindex="0"><code>FT.SEARCH books-idx "@title:dogs" </code></pre> </li> </ul> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/develop/interact/search-and-query/basic-constructs/field-and-type-options/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/json.clear/.html
<section class="prose w-full py-12"> <h1 class="command-name"> JSON.CLEAR </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">JSON.CLEAR key [path]</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available in: </dt> <dd class="m-0"> <a href="/docs/stack"> Redis Stack </a> / <a href="/docs/data-types/json"> JSON 2.0.0 </a> </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(N) when path is evaluated to a single value where N is the size of the values, O(N) when path is evaluated to multiple values, where N is the size of the key </dd> </dl> <p> Clear container values (arrays/objects) and set numeric values to <code> 0 </code> </p> <p> <a href="#examples"> Examples </a> </p> <h2 id="required-arguments"> Required arguments </h2> <details open=""> <summary> <code> key </code> </summary> <p> is key to parse. </p> </details> <h2 id="optional-arguments"> Optional arguments </h2> <details open=""> <summary> <code> path </code> </summary> <p> is JSONPath to specify. Default is root <code> $ </code> . Nonexisting paths are ignored. </p> </details> <h2 id="return"> Return </h2> <p> JSON.CLEAR returns an integer reply specifying the number of matching JSON arrays and objects cleared + number of matching JSON numerical values zeroed. For more information about replies, see <a href="/docs/latest/develop/reference/protocol-spec/"> Redis serialization protocol specification </a> . </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> Already cleared values are ignored for empty containers and zero numbers. </div> </div> <h2 id="examples"> Examples </h2> <details open=""> <summary> <b> Clear container values and set numeric values to <code> 0 </code> </b> </summary> <p> Create a JSON document. </p> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis&gt; JSON.SET doc $ <span class="s1">'{"obj":{"a":1, "b":2}, "arr":[1,2,3], "str": "foo", "bool": true, "int": 42, "float": 3.14}'</span> </span></span><span class="line"><span class="cl">OK</span></span></code></pre> </div> <p> Clear all container values. This returns the number of objects with cleared values. </p> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis&gt; JSON.CLEAR doc $.* </span></span><span class="line"><span class="cl"><span class="o">(</span>integer<span class="o">)</span> <span class="m">4</span></span></span></code></pre> </div> <p> Get the updated document. Note that numeric values have been set to <code> 0 </code> . </p> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis&gt; JSON.GET doc $ </span></span><span class="line"><span class="cl"><span class="s2">"[{\"obj\":{},\"arr\":[],\"str\":\"foo\",\"bool\":true,\"int\":0,\"float\":0}]"</span></span></span></code></pre> </div> </details> <h2 id="see-also"> See also </h2> <p> <a href="/docs/latest/commands/json.arrindex/"> <code> JSON.ARRINDEX </code> </a> | <a href="/docs/latest/commands/json.arrinsert/"> <code> JSON.ARRINSERT </code> </a> </p> <h2 id="related-topics"> Related topics </h2> <ul> <li> <a href="/docs/latest/develop/data-types/json/"> RedisJSON </a> </li> <li> <a href="/docs/latest/develop/interact/search-and-query/indexing/"> Index and search JSON documents </a> </li> </ul> <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/json.clear/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/lmove/.html
<section class="prose w-full py-12"> <h1 class="command-name"> LMOVE </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">LMOVE source destination &lt;LEFT | RIGHT&gt; &lt;LEFT | RIGHT&gt;</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available since: </dt> <dd class="m-0"> 6.2.0 </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(1) </dd> <dt class="font-semibold text-redis-ink-900 m-0"> ACL categories: </dt> <dd class="m-0"> <code> @write </code> <span class="mr-1 last:hidden"> , </span> <code> @list </code> <span class="mr-1 last:hidden"> , </span> <code> @slow </code> <span class="mr-1 last:hidden"> , </span> </dd> </dl> <p> Atomically returns and removes the first/last element (head/tail depending on the <code> wherefrom </code> argument) of the list stored at <code> source </code> , and pushes the element at the first/last element (head/tail depending on the <code> whereto </code> argument) of the list stored at <code> destination </code> . </p> <p> For example: consider <code> source </code> holding the list <code> a,b,c </code> , and <code> destination </code> holding the list <code> x,y,z </code> . Executing <code> LMOVE source destination RIGHT LEFT </code> results in <code> source </code> holding <code> a,b </code> and <code> destination </code> holding <code> c,x,y,z </code> . </p> <p> If <code> source </code> does not exist, the value <code> nil </code> is returned and no operation is performed. If <code> source </code> and <code> destination </code> are the same, the operation is equivalent to removing the first/last element from the list and pushing it as first/last element of the list, so it can be considered as a list rotation command (or a no-op if <code> wherefrom </code> is the same as <code> whereto </code> ). </p> <p> This command comes in place of the now deprecated <a href="/docs/latest/commands/rpoplpush/"> <code> RPOPLPUSH </code> </a> . Doing <code> LMOVE RIGHT LEFT </code> is equivalent. </p> <h2 id="examples"> Examples </h2> <div class="bg-slate-900 border-b border-slate-700 rounded-t-xl px-4 py-3 w-full flex"> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M2.5 10C2.5 5.85786 5.85786 2.5 10 2.5C14.1421 2.5 17.5 5.85786 17.5 10C17.5 14.1421 14.1421 17.5 10 17.5C5.85786 17.5 2.5 14.1421 2.5 10Z"> </path> </svg> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M10 2.5L18.6603 17.5L1.33975 17.5L10 2.5Z"> </path> </svg> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M10 2.5L12.0776 7.9322L17.886 8.22949L13.3617 11.8841L14.8738 17.5L10 14.3264L5.1262 17.5L6.63834 11.8841L2.11403 8.22949L7.92238 7.9322L10 2.5Z"> </path> </svg> </div> <form class="redis-cli overflow-y-auto max-h-80"> <pre tabindex="0">redis&gt; RPUSH mylist "one" (integer) 1 redis&gt; RPUSH mylist "two" (integer) 2 redis&gt; RPUSH mylist "three" (integer) 3 redis&gt; LMOVE mylist myotherlist RIGHT LEFT "three" redis&gt; LMOVE mylist myotherlist LEFT RIGHT "one" redis&gt; LRANGE mylist 0 -1 1) "two" redis&gt; LRANGE myotherlist 0 -1 1) "three" 2) "one" </pre> <div class="prompt" style=""> <span> redis&gt; </span> <input autocomplete="off" name="prompt" spellcheck="false" type="text"/> </div> </form> <h2 id="pattern-reliable-queue"> Pattern: Reliable queue </h2> <p> Redis is often used as a messaging server to implement processing of background jobs or other kinds of messaging tasks. A simple form of queue is often obtained pushing values into a list in the producer side, and waiting for this values in the consumer side using <a href="/docs/latest/commands/rpop/"> <code> RPOP </code> </a> (using polling), or <a href="/docs/latest/commands/brpop/"> <code> BRPOP </code> </a> if the client is better served by a blocking operation. </p> <p> However in this context the obtained queue is not <em> reliable </em> as messages can be lost, for example in the case there is a network problem or if the consumer crashes just after the message is received but it is still to process. </p> <p> <code> LMOVE </code> (or <a href="/docs/latest/commands/blmove/"> <code> BLMOVE </code> </a> for the blocking variant) offers a way to avoid this problem: the consumer fetches the message and at the same time pushes it into a <em> processing </em> list. It will use the <a href="/docs/latest/commands/lrem/"> <code> LREM </code> </a> command in order to remove the message from the <em> processing </em> list once the message has been processed. </p> <p> An additional client may monitor the <em> processing </em> list for items that remain there for too much time, and will push those timed out items into the queue again if needed. </p> <h2 id="pattern-circular-list"> Pattern: Circular list </h2> <p> Using <code> LMOVE </code> with the same source and destination key, a client can visit all the elements of an N-elements list, one after the other, in O(N) without transferring the full list from the server to the client using a single <a href="/docs/latest/commands/lrange/"> <code> LRANGE </code> </a> operation. </p> <p> The above pattern works even in the following conditions: </p> <ul> <li> There are multiple clients rotating the list: they'll fetch different elements, until all the elements of the list are visited, and the process restarts. </li> <li> Even if other clients are actively pushing new items at the end of the list. </li> </ul> <p> The above makes it very simple to implement a system where a set of items must be processed by N workers continuously as fast as possible. An example is a monitoring system that must check that a set of web sites are reachable, with the smallest delay possible, using a number of parallel workers. </p> <p> Note that this implementation of workers is trivially scalable and reliable, because even if a message is lost the item is still in the queue and will be processed at the next iteration. </p> <h2 id="resp2resp3-reply"> RESP2/RESP3 Reply </h2> <a href="../../develop/reference/protocol-spec#bulk-strings"> Bulk string reply </a> : the element being popped and pushed. <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/lmove/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/references/rest-api/objects/shard/backup/.html
<section class="prose w-full py-12 max-w-none"> <h1> Backup object </h1> <p class="text-lg -mt-5 mb-10"> Documents the backup object used with Redis Enterprise Software REST API calls. </p> <table> <thead> <tr> <th> Name </th> <th> Type/Value </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> progress </td> <td> number, (range: 0-100) </td> <td> Shard backup progress (percentage) </td> </tr> <tr> <td> status </td> <td> 'exporting' <br/> 'succeeded' <br/> 'failed' </td> <td> Status of scheduled periodic backup process </td> </tr> </tbody> </table> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/references/rest-api/objects/shard/backup/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/slowlog-help/.html
<section class="prose w-full py-12"> <h1 class="command-name"> SLOWLOG HELP </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">SLOWLOG HELP</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available since: </dt> <dd class="m-0"> 6.2.0 </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(1) </dd> <dt class="font-semibold text-redis-ink-900 m-0"> ACL categories: </dt> <dd class="m-0"> <code> @slow </code> <span class="mr-1 last:hidden"> , </span> </dd> </dl> <p> The <code> SLOWLOG HELP </code> command returns a helpful text describing the different subcommands. </p> <h2 id="resp2resp3-reply"> RESP2/RESP3 Reply </h2> <a href="../../develop/reference/protocol-spec#arrays"> Array reply </a> : a list of sub-commands and their descriptions. <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/slowlog-help/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/zrangebylex/.html
<section class="prose w-full py-12"> <h1 class="command-name"> ZRANGEBYLEX <span class="text-base"> (deprecated) </span> </h1> <div class="border-l-8 pl-4"> <p> As of Redis version 6.2.0, this command is regarded as deprecated. </p> <p> It can be replaced by <a href="/docs/latest/commands/zrange/"> <code> ZRANGE </code> </a> with the <code> BYLEX </code> argument when migrating or writing new code. </p> </div> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">ZRANGEBYLEX key min max [LIMIT offset count]</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available since: </dt> <dd class="m-0"> 2.8.9 </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements being returned. If M is constant (e.g. always asking for the first 10 elements with LIMIT), you can consider it O(log(N)). </dd> <dt class="font-semibold text-redis-ink-900 m-0"> ACL categories: </dt> <dd class="m-0"> <code> @read </code> <span class="mr-1 last:hidden"> , </span> <code> @sortedset </code> <span class="mr-1 last:hidden"> , </span> <code> @slow </code> <span class="mr-1 last:hidden"> , </span> </dd> </dl> <p> When all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering, this command returns all the elements in the sorted set at <code> key </code> with a value between <code> min </code> and <code> max </code> . </p> <p> If the elements in the sorted set have different scores, the returned elements are unspecified. </p> <p> The elements are considered to be ordered from lower to higher strings as compared byte-by-byte using the <code> memcmp() </code> C function. Longer strings are considered greater than shorter strings if the common part is identical. </p> <p> The optional <code> LIMIT </code> argument can be used to only get a range of the matching elements (similar to <em> SELECT LIMIT offset, count </em> in SQL). A negative <code> count </code> returns all elements from the <code> offset </code> . Keep in mind that if <code> offset </code> is large, the sorted set needs to be traversed for <code> offset </code> elements before getting to the elements to return, which can add up to O(N) time complexity. </p> <h2 id="how-to-specify-intervals"> How to specify intervals </h2> <p> Valid <em> start </em> and <em> stop </em> must start with <code> ( </code> or <code> [ </code> , in order to specify if the range item is respectively exclusive or inclusive. The special values of <code> + </code> or <code> - </code> for <em> start </em> and <em> stop </em> have the special meaning or positively infinite and negatively infinite strings, so for instance the command <strong> ZRANGEBYLEX myzset - + </strong> is guaranteed to return all the elements in the sorted set, if all the elements have the same score. </p> <h2 id="details-on-strings-comparison"> Details on strings comparison </h2> <p> Strings are compared as binary array of bytes. Because of how the ASCII character set is specified, this means that usually this also have the effect of comparing normal ASCII characters in an obvious dictionary way. However this is not true if non plain ASCII strings are used (for example utf8 strings). </p> <p> However the user can apply a transformation to the encoded string so that the first part of the element inserted in the sorted set will compare as the user requires for the specific application. For example if I want to add strings that will be compared in a case-insensitive way, but I still want to retrieve the real case when querying, I can add strings in the following way: </p> <pre><code>ZADD autocomplete 0 foo:Foo 0 bar:BAR 0 zap:zap </code></pre> <p> Because of the first <em> normalized </em> part in every element (before the colon character), we are forcing a given comparison, however after the range is queries using <code> ZRANGEBYLEX </code> the application can display to the user the second part of the string, after the colon. </p> <p> The binary nature of the comparison allows to use sorted sets as a general purpose index, for example the first part of the element can be a 64 bit big endian number: since big endian numbers have the most significant bytes in the initial positions, the binary comparison will match the numerical comparison of the numbers. This can be used in order to implement range queries on 64 bit values. As in the example below, after the first 8 bytes we can store the value of the element we are actually indexing. </p> <h2 id="examples"> Examples </h2> <div class="bg-slate-900 border-b border-slate-700 rounded-t-xl px-4 py-3 w-full flex"> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M2.5 10C2.5 5.85786 5.85786 2.5 10 2.5C14.1421 2.5 17.5 5.85786 17.5 10C17.5 14.1421 14.1421 17.5 10 17.5C5.85786 17.5 2.5 14.1421 2.5 10Z"> </path> </svg> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M10 2.5L18.6603 17.5L1.33975 17.5L10 2.5Z"> </path> </svg> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M10 2.5L12.0776 7.9322L17.886 8.22949L13.3617 11.8841L14.8738 17.5L10 14.3264L5.1262 17.5L6.63834 11.8841L2.11403 8.22949L7.92238 7.9322L10 2.5Z"> </path> </svg> </div> <form class="redis-cli overflow-y-auto max-h-80"> <pre tabindex="0">redis&gt; ZADD myzset 0 a 0 b 0 c 0 d 0 e 0 f 0 g (integer) 7 redis&gt; ZRANGEBYLEX myzset - [c 1) "a" 2) "b" 3) "c" redis&gt; ZRANGEBYLEX myzset - (c 1) "a" 2) "b" redis&gt; ZRANGEBYLEX myzset [aaa (g 1) "b" 2) "c" 3) "d" 4) "e" 5) "f" </pre> <div class="prompt" style=""> <span> redis&gt; </span> <input autocomplete="off" name="prompt" spellcheck="false" type="text"/> </div> </form> <h2 id="resp2resp3-reply"> RESP2/RESP3 Reply </h2> <a href="../../develop/reference/protocol-spec#arrays"> Array reply </a> : a list of elements in the specified score range. <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/zrangebylex/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/7.4/references/rest-api/requests/endpoints-stats/.html
<section class="prose w-full py-12 max-w-none"> <h1> Endpoints stats requests </h1> <p class="text-lg -mt-5 mb-10"> Endpoint statistics requests </p> <table> <thead> <tr> <th> Method </th> <th> Path </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="#get-endpoints-stats"> GET </a> </td> <td> <code> /v1/endpoints/stats </code> </td> <td> Get stats for all endpoints </td> </tr> </tbody> </table> <h2 id="get-endpoints-stats"> Get all endpoints stats </h2> <pre><code>GET /v1/endpoints/stats </code></pre> <p> Get statistics for all endpoint-proxy links. </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> This method will return both endpoints and listeners stats for backwards compatability. </div> </div> <h4 id="required-permissions"> Required permissions </h4> <table> <thead> <tr> <th> Permission name </th> </tr> </thead> <tbody> <tr> <td> <a href="/docs/latest/operate/rs/7.4/references/rest-api/permissions/#view_endpoint_stats"> view_endpoint_stats </a> </td> </tr> </tbody> </table> <h3 id="get-request"> Request </h3> <h4 id="example-http-request"> Example HTTP request </h4> <pre><code>GET /endpoints/stats?interval=1hour&amp;stime=2014-08-28T10:00:00Z </code></pre> <h4 id="request-headers"> Request headers </h4> <table> <thead> <tr> <th> Key </th> <th> Value </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> Host </td> <td> cnm.cluster.fqdn </td> <td> Domain name </td> </tr> <tr> <td> Accept </td> <td> application/json </td> <td> Accepted media type </td> </tr> </tbody> </table> <h4 id="query-parameters"> Query parameters </h4> <table> <thead> <tr> <th> Field </th> <th> Type </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> interval </td> <td> string </td> <td> Time interval for which we want stats: 1sec/10sec/5min/15min/1hour/12hour/1week (optional) </td> </tr> <tr> <td> stime </td> <td> ISO_8601 </td> <td> Start time from which we want the stats. Should comply with the <a href="https://en.wikipedia.org/wiki/ISO_8601"> ISO_8601 </a> format (optional) </td> </tr> <tr> <td> etime </td> <td> ISO_8601 </td> <td> End time after which we don't want the stats. Should comply with the <a href="https://en.wikipedia.org/wiki/ISO_8601"> ISO_8601 </a> format (optional) </td> </tr> </tbody> </table> <h3 id="get-response"> Response </h3> <p> The <code> uid </code> format in the response is: <code> "BDB_UID:ENDPOINT_UID:PROXY_UID" </code> </p> <p> For example: <code> {"uid": "1:2:3"} </code> means <code> BDB_UID=1 </code> , <code> ENDPOINT_UID=2 </code> , and <code> PROXY_UID=3 </code> </p> <h4 id="example-json-body"> Example JSON body </h4> <div class="highlight"> <pre class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl"><span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"uid"</span> <span class="p">:</span> <span class="s2">"365:1:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"intervals"</span> <span class="p">:</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"interval"</span> <span class="p">:</span> <span class="s2">"10sec"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"total_req"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"egress_bytes"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"cmd_get"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"monitor_sessions_count"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"auth_errors"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"acc_latency"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"stime"</span> <span class="p">:</span> <span class="s2">"2017-01-12T14:59:50Z"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"write_res"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"total_connections_received"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"cmd_set"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"read_req"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"max_connections_exceeded"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"acc_write_latency"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"write_req"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"other_res"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"cmd_flush"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"acc_read_latency"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"other_req"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"conns"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"write_started_res"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"cmd_touch"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"read_res"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"auth_cmds"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"etime"</span> <span class="p">:</span> <span class="s2">"2017-01-12T15:00:00Z"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"total_started_res"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"ingress_bytes"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"last_res_time"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"read_started_res"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"acc_other_latency"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"total_res"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"last_req_time"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"other_started_res"</span> <span class="p">:</span> <span class="mi">0</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="p">]</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"intervals"</span> <span class="p">:</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"acc_read_latency"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"other_req"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"etime"</span> <span class="p">:</span> <span class="s2">"2017-01-12T15:00:00Z"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"auth_cmds"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"total_started_res"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"write_started_res"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"cmd_touch"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"conns"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"read_res"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"total_res"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"other_started_res"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"last_req_time"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"read_started_res"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"last_res_time"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"ingress_bytes"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"acc_other_latency"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"egress_bytes"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"interval"</span> <span class="p">:</span> <span class="s2">"10sec"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"total_req"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"acc_latency"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"auth_errors"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"cmd_get"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"monitor_sessions_count"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"read_req"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"max_connections_exceeded"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"total_connections_received"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"cmd_set"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"acc_write_latency"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"write_req"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"stime"</span> <span class="p">:</span> <span class="s2">"2017-01-12T14:59:50Z"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"write_res"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"cmd_flush"</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"other_res"</span> <span class="p">:</span> <span class="mi">0</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="nt">"uid"</span> <span class="p">:</span> <span class="s2">"333:1:2"</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">]</span> </span></span></code></pre> </div> <h3 id="get-status-codes"> Status codes </h3> <table> <thead> <tr> <th> Code </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1"> 200 OK </a> </td> <td> No error </td> </tr> </tbody> </table> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/references/rest-api/requests/endpoints-stats/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/integrate/redis-data-integration/data-pipelines/prepare-dbs/sql-server/.html
<section class="prose w-full py-12 max-w-none"> <h1> Prepare SQL Server for RDI </h1> <p class="text-lg -mt-5 mb-10"> Prepare SQL Server databases to work with RDI </p> <p> To prepare your SQL Server database for Debezium, you must first run a query to enable CDC globally and then separately enable CDC for each table you want to capture. You need administrator privileges to do this. </p> <p> Once you enable CDC, it captures all of the INSERT, UPDATE, and DELETE operations on your chosen tables. The Debezium connector can then emit these events to <a href="https://kafka.apache.org/intro#intro_concepts_and_terms"> Kafka topics </a> . </p> <h2 id="1-enable-cdc-on-the-database"> 1. Enable CDC on the database </h2> <p> There are two system stored procedures to enable CDC (you need administrator privileges to run these). Use <code> sys.sp_cdc_enable_db </code> to enable CDC for the whole database and then You can run the procedure with SQL Server Management Studio or with Transact-SQL. </p> <p> Before running the procedure, ensure that: </p> <ul> <li> You are a member of the <code> sysadmin </code> fixed server role for the SQL Server. </li> <li> You are a <code> db_owner </code> of the database. </li> <li> The SQL Server Agent is running. </li> </ul> <p> Then, follow the steps below to enable CDC: </p> <ol> <li> <p> From the <strong> View </strong> menu in SQL Server Management Studio, click <strong> Template Explorer </strong> . </p> </li> <li> <p> In the Template Browser, expand <strong> SQL Server Templates </strong> . </p> </li> <li> <p> Expand <strong> Change Data Capture &gt; Configuration </strong> and then click <strong> Enable Database for CDC </strong> . </p> </li> <li> <p> In the template, replace the database name in the <code> USE </code> statement with the name of the database where you want to enable CDC. For example, if your database was called <code> myDB </code> , the template would be: </p> <div class="highlight"> <pre class="chroma"><code class="language-sql" data-lang="sql"><span class="line"><span class="cl"><span class="n">USE</span><span class="w"> </span><span class="n">MyDB</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="k">GO</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="k">EXEC</span><span class="w"> </span><span class="n">sys</span><span class="p">.</span><span class="n">sp_cdc_enable_db</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="k">GO</span><span class="w"> </span></span></span></code></pre> </div> </li> <li> <p> Run the stored procedure <code> sys.sp_cdc_enable_db </code> to enable CDC for the database. </p> </li> </ol> <p> When you enable CDC for the database, it creates a schema called <code> cdc </code> and also a CDC user, metadata tables, and other system objects. </p> <p> Keep the <strong> Change Data Capture &gt; Configuration </strong> foldout open in the Template Explorer because you will need it to enable CDC on the individual tables next. </p> <h2 id="2-enable-cdc-for-the-tables-you-want-to-capture"> 2. Enable CDC for the tables you want to capture </h2> <p> You must also enable CDC on the tables you want Debezium to capture using the following steps (again, you need administrator privileges for this): </p> <ol> <li> <p> With the <strong> Change Data Capture &gt; Configuration </strong> foldout still open in the Template Explorer, select <strong> Enable Table Specifying Filegroup Option </strong> . </p> </li> <li> <p> In the template, replace the table name in the USE statement with the name of the table you want to capture. For example, if your table was called <code> MyTable </code> then the template would look like the following: </p> <div class="highlight"> <pre class="chroma"><code class="language-sql" data-lang="sql"><span class="line"><span class="cl"><span class="n">USE</span><span class="w"> </span><span class="n">MyDB</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="k">GO</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="k">EXEC</span><span class="w"> </span><span class="n">sys</span><span class="p">.</span><span class="n">sp_cdc_enable_table</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="o">@</span><span class="n">source_schema</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">N</span><span class="s1">'dbo'</span><span class="p">,</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="o">@</span><span class="n">source_name</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">N</span><span class="s1">'MyTable'</span><span class="p">,</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="o">@</span><span class="n">role_name</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">N</span><span class="s1">'MyRole'</span><span class="p">,</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="o">@</span><span class="n">filegroup_name</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">N</span><span class="s1">'MyDB_CT'</span><span class="p">,</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="o">@</span><span class="n">supports_net_changes</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="k">GO</span><span class="w"> </span></span></span></code></pre> </div> </li> <li> <p> Run the stored procedure <code> sys.sp_cdc_enable_table </code> to enable CDC for the table. </p> </li> <li> <p> Repeat steps 1 to 3 for every table you want to capture. </p> </li> </ol> <h2 id="3-check-that-you-have-access-to-the-cdc-table"> 3. Check that you have access to the CDC table </h2> <p> You can use another stored procedure <code> sys.sp_cdc_help_change_data_capture </code> to query the CDC information for the database and check you have enabled it correctly. Before doing this, check that: </p> <ul> <li> You have <code> SELECT </code> permission on all of the captured columns of the capture instance. If you are a member of the <code> db_owner </code> database role then you can view information for all of the defined capture instances. </li> <li> You are a member of any gating roles that are defined for the table that the query includes. </li> </ul> <p> Follow the steps below to run <code> sys.sp_cdc_help_change_data_capture </code> : </p> <ol> <li> <p> From the <strong> View </strong> menu in SQL Server Management Studio, click <strong> Object Explorer </strong> . </p> </li> <li> <p> From the Object Explorer, expand <strong> Databases </strong> , and then expand your database object, for example, <code> MyDB </code> . </p> </li> <li> <p> Expand <strong> Programmability &gt; Stored Procedures &gt; System Stored Procedures </strong> . </p> </li> <li> <p> Run the <code> sys.sp_cdc_help_change_data_capture </code> stored procedure to query the table. For example, if your database was called <code> MyDB </code> then you would run the following: </p> <div class="highlight"> <pre class="chroma"><code class="language-sql" data-lang="sql"><span class="line"><span class="cl"><span class="n">USE</span><span class="w"> </span><span class="n">MyDB</span><span class="p">;</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="k">GO</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="k">EXEC</span><span class="w"> </span><span class="n">sys</span><span class="p">.</span><span class="n">sp_cdc_help_change_data_capture</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="k">GO</span><span class="w"> </span></span></span></code></pre> </div> </li> <li> <p> The query returns configuration information for each table in the database that has CDC enabled and that contains change data that you are authorized to access. If the result is empty then you should check that you have privileges to access both the capture instance and the CDC tables. </p> </li> </ol> <h2 id="sql-server-on-azure"> SQL Server on Azure </h2> <p> You can also use the Debezium SQL Server connector with SQL Server on Azure. See Microsoft's guide to <a href="https://learn.microsoft.com/en-us/samples/azure-samples/azure-sql-db-change-stream-debezium/azure-sql%2D%2Dsql-server-change-stream-with-debezium/"> configuring SQL Server on Azure for CDC with Debezium </a> for more information. </p> <h3 id="sql-server-capture-job-agent-configuration-parameters"> SQL Server capture job agent configuration parameters </h3> <p> In SQL Server, the parameters that control the behavior of the capture job agent are defined in the SQL Server table <code> msdb.dbo.cdc_jobs </code> . If you experience performance problems while running the capture job agent then you can adjust the capture jobs settings to reduce CPU load. To do this, run the <code> sys.sp_cdc_change_job </code> stored procedure with your new parameter values. </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> A full guide to configuring the SQL Server capture job agent parameters is outside the scope of the Redis documentation. </div> </div> <p> The following parameters are the most important ones for modifying the capture agent behavior of the Debezium SQL Server connector: </p> <ul> <li> <code> pollinginterval </code> : This specifies the number of seconds that the capture agent waits between log scan cycles. A higher value reduces the load on the database host, but increases latency. A value of 0 specifies no wait between scans. The default value is 5. </li> <li> <code> maxtrans </code> : This specifies the maximum number of transactions to process during each log scan cycle. After the capture job processes the specified number of transactions, it pauses for the length of time that <code> pollinginterval </code> specifies before the next scan begins. A lower value reduces the load on the database host, but increases latency. The default value is 500. </li> <li> <code> maxscans </code> : This specifies a limit on the number of scan cycles that the capture job can attempt when capturing the full contents of the database transaction log. If the continuous parameter is set to 1, the job pauses for the length of time that the <code> pollinginterval </code> specifies before it resumes scanning. A lower values reduces the load on the database host, but increases latency. The default value is 10. </li> </ul> <p> See the SQL Server documentation for more information about capture agent parameters. </p> <h2 id="handling-changes-to-the-schema"> Handling changes to the schema </h2> <p> RDI can't adapt automatically when you change the schema of a CDC table in SQL Server. For example, if you add a new column to a table you are capturing then RDI will generate errors instead of capturing the changes correctly. See Debezium's <a href="https://debezium.io/documentation/reference/stable/connectors/sqlserver.html#sqlserver-schema-evolution"> SQL Server schema evolution </a> docs for more information. </p> <p> If you have administrator privileges, you can follow the steps below to update RDI after a schema change and resume CDC. See the <a href="https://debezium.io/documentation/reference/stable/connectors/sqlserver.html#online-schema-updates"> online schema updates </a> documentation for further details. </p> <ol> <li> <p> Make your changes to the source table schema. </p> </li> <li> <p> Create a new capture table for the updated source table by running the <code> sys.sp_cdc_enable_table </code> stored procedure with a new, unique value for the parameter <code> @capture_instance </code> . For example, if the old value was <code> dbo_customers </code> , you could replace it with <code> dbo_customers_v2 </code> : </p> <div class="highlight"> <pre class="chroma"><code class="language-sql" data-lang="sql"><span class="line"><span class="cl"><span class="k">EXEC</span><span class="w"> </span><span class="n">sys</span><span class="p">.</span><span class="n">sp_cdc_enable_table</span><span class="w"> </span><span class="o">@</span><span class="n">source_schema</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'dbo'</span><span class="p">,</span><span class="w"> </span><span class="o">@</span><span class="n">source_name</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'customers'</span><span class="p">,</span><span class="w"> </span><span class="o">@</span><span class="n">role_name</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">NULL</span><span class="p">,</span><span class="w"> </span><span class="o">@</span><span class="n">supports_net_changes</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="o">@</span><span class="n">capture_instance</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'dbo_customers_v2'</span><span class="p">;</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="k">GO</span><span class="w"> </span></span></span></code></pre> </div> </li> <li> <p> When Debezium starts streaming from the new capture table, drop the old capture table by running the <code> sys.sp_cdc_disable_table </code> stored procedure with the parameter <code> @capture_instance </code> set to the old capture instance name, <code> dbo_customers </code> : </p> <div class="highlight"> <pre class="chroma"><code class="language-sql" data-lang="sql"><span class="line"><span class="cl"><span class="k">EXEC</span><span class="w"> </span><span class="n">sys</span><span class="p">.</span><span class="n">sp_cdc_disable_table</span><span class="w"> </span><span class="o">@</span><span class="n">source_schema</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'dbo'</span><span class="p">,</span><span class="w"> </span><span class="o">@</span><span class="n">source_name</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'dbo_customers'</span><span class="p">,</span><span class="w"> </span><span class="o">@</span><span class="n">capture_instance</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'dbo_customers'</span><span class="p">;</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="k">GO</span><span class="w"> </span></span></span></code></pre> </div> </li> </ol> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> RDI will <em> not </em> correctly capture changes that happen in the time gap between changing the source schema (step 1 above) and updating the value of <code> @capture_instance </code> (step 2). Try to keep the gap as short as possible or perform the update at a time when you expect few changes to the data. </div> </div> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/integrate/redis-data-integration/data-pipelines/prepare-dbs/sql-server/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/gears-v1/jvm/classes/readers/commandreader/.html
<section class="prose w-full py-12 max-w-none"> <h1> CommandReader </h1> <p class="text-lg -mt-5 mb-10"> Run RedisGears functions on command. </p> <p> The <code> CommandReader </code> allows you to run RedisGears functions on command when you: </p> <ol> <li> <p> Pass the <code> CommandReader </code> to the <a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/gears-v1/jvm/classes/gearsbuilder/creategearsbuilder/"> <code> GearsBuilder.CreateGearsBuilder() </code> </a> function in your Java code. </p> </li> <li> <p> Call the <a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/gears-v1/jvm/classes/gearsbuilder/register/"> <code> register() </code> </a> function. </p> </li> <li> <p> Run <code> RG.JEXECUTE </code> to register your code. </p> </li> <li> <p> Use <code> RG.TRIGGER </code> to run your code on command: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">RG.TRIGGER &lt;Trigger name&gt; <span class="o">[</span>arg1 arg2 ...<span class="o">]</span> </span></span></code></pre> </div> </li> </ol> <h2 id="parameters"> Parameters </h2> <table> <thead> <tr> <th> Name </th> <th> Type </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> trigger </td> <td> string </td> <td> The command name that triggers the registered RedisGears functions to run </td> </tr> </tbody> </table> <h2 id="output-records"> Output records </h2> <p> Outputs a record with the command trigger's name and arguments. </p> <h2 id="example"> Example </h2> <p> The following example shows how to create a custom command to update an item's stock. It also adds a timestamp to track when the last restock occurred. </p> <p> Add a hash to the database that represents an inventory item: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">redis&gt; HSET inventory🎧1 color <span class="s2">"blue"</span> stock <span class="m">5</span> price 30.00 </span></span><span class="line"><span class="cl"><span class="o">(</span>integer<span class="o">)</span> <span class="m">3</span> </span></span></code></pre> </div> <p> Example code: </p> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="c1">// Create the reader that will pass data to the pipe </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="n">CommandReader</span> <span class="n">reader</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CommandReader</span><span class="o">();</span> </span></span><span class="line"><span class="cl"><span class="c1">// Set the name of the custom command </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="n">reader</span><span class="o">.</span><span class="na">setTrigger</span><span class="o">(</span><span class="s">"Restock"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="c1">// Create the data pipe builder </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="n">GearsBuilder</span><span class="o">.</span><span class="na">CreateGearsBuilder</span><span class="o">(</span><span class="n">reader</span><span class="o">).</span><span class="na">map</span><span class="o">(</span><span class="n">r</span><span class="o">-&gt;</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="c1">// Parse the command arguments to get the key name and new stock value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="n">String</span> <span class="n">itemKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">String</span><span class="o">((</span><span class="kt">byte</span><span class="o">[])</span> <span class="n">r</span><span class="o">[</span><span class="mi">1</span><span class="o">],</span> <span class="n">StandardCharsets</span><span class="o">.</span><span class="na">UTF_8</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">newStock</span> <span class="o">=</span> <span class="k">new</span> <span class="n">String</span><span class="o">((</span><span class="kt">byte</span><span class="o">[])</span> <span class="n">r</span><span class="o">[</span><span class="mi">2</span><span class="o">],</span> <span class="n">StandardCharsets</span><span class="o">.</span><span class="na">UTF_8</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Update the item's stock and add a timestamp </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="n">GearsBuilder</span><span class="o">.</span><span class="na">execute</span><span class="o">(</span><span class="s">"HSET"</span><span class="o">,</span> <span class="n">itemKey</span> <span class="o">,</span> <span class="s">"stock"</span><span class="o">,</span> <span class="n">newStock</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"last_restocked"</span><span class="o">,</span> <span class="n">Long</span><span class="o">.</span><span class="na">toString</span><span class="o">(</span><span class="n">System</span><span class="o">.</span><span class="na">currentTimeMillis</span><span class="o">()));</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">return</span> <span class="s">"OK restocked "</span> <span class="o">+</span> <span class="n">itemKey</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="o">}).</span><span class="na">register</span><span class="o">();</span> </span></span></code></pre> </div> <p> After you register the previous code with the <code> RG.JEXECUTE </code> command, run <code> RG.TRIGGER </code> to test it: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">redis&gt; RG.TRIGGER Restock inventory🎧1 <span class="m">20</span> </span></span><span class="line"><span class="cl">1<span class="o">)</span> <span class="s2">"OK restocked inventory🎧1"</span> </span></span></code></pre> </div> <p> The item now has the updated value for <code> stock </code> and a <code> last_restocked </code> timestamp: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">redis&gt; HGETALL inventory🎧1 </span></span><span class="line"><span class="cl">1<span class="o">)</span> <span class="s2">"color"</span> </span></span><span class="line"><span class="cl">2<span class="o">)</span> <span class="s2">"blue"</span> </span></span><span class="line"><span class="cl">3<span class="o">)</span> <span class="s2">"stock"</span> </span></span><span class="line"><span class="cl">4<span class="o">)</span> <span class="s2">"20"</span> </span></span><span class="line"><span class="cl">5<span class="o">)</span> <span class="s2">"price"</span> </span></span><span class="line"><span class="cl">6<span class="o">)</span> <span class="s2">"30.00"</span> </span></span><span class="line"><span class="cl">7<span class="o">)</span> <span class="s2">"last_restocked"</span> </span></span><span class="line"><span class="cl">8<span class="o">)</span> <span class="s2">"1643232394078"</span> </span></span></code></pre> </div> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/gears-v1/jvm/classes/readers/commandreader/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/references/metrics/database-operations/.html
<section class="prose w-full py-12 max-w-none"> <h1> Database operations metrics </h1> <h2 id="evicted-objectssec"> Evicted objects/sec </h2> <p> Number of objects evicted from the database per second. </p> <p> Objects are evicted from the database according to the <a href="/docs/latest/operate/rs/databases/memory-performance/eviction-policy/"> eviction policy </a> . </p> <p> Object information is not measured during <a href="/docs/latest/operate/rs/databases/configure/replica-ha/"> shard migration </a> . </p> <p> <strong> Components measured </strong> : Database and Shard </p> <h2 id="expired-objectssec"> Expired objects/sec </h2> <p> Number of expired objects per second. </p> <p> Object information is not measured during <a href="/docs/latest/operate/rs/databases/configure/replica-ha/"> shard migration </a> . </p> <p> <strong> Components measured </strong> : Database and Shard </p> <h2 id="hit-ratio"> Hit ratio </h2> <p> Ratio of the number of operations on existing keys out of the total number of operations. </p> <p> <strong> Components measured </strong> : Database and Shard </p> <h3 id="read-missessec"> Read misses/sec </h3> <p> The number of <a href="#readssec"> read operations </a> per second on keys that do not exist. </p> <p> Read misses are not measured during <a href="/docs/latest/operate/rs/databases/configure/replica-ha/"> shard migration </a> . </p> <p> <strong> Components measured </strong> : Database </p> <h3 id="write-missessec"> Write misses/sec </h3> <p> Number of <a href="#writessec"> write operations </a> per second on keys that do not exist. </p> <p> Write misses are not measured during <a href="/docs/latest/operate/rs/databases/configure/replica-ha/"> shard migration </a> . </p> <p> <strong> Components measured </strong> : Database and Shard </p> <h2 id="latency"> Latency </h2> <p> The total amount of time between sending a Redis operation and receiving a response from the database. </p> <p> The graph shows average, minimum, maximum, and last latency values for all latency metrics. </p> <p> <strong> Components measured </strong> : Database </p> <h3 id="reads-latency"> Reads latency </h3> <p> <a href="#latency"> Latency </a> of <a href="#readssec"> read operations </a> . </p> <p> <strong> Components measured </strong> : Database </p> <h3 id="writes-latency"> Writes latency </h3> <p> <a href="#latency"> Latency </a> per <a href="#writessec"> write operation </a> . </p> <p> <strong> Components measured </strong> : Database </p> <h3 id="other-commands-latency"> Other commands latency </h3> <p> <a href="#latency"> Latency </a> of <a href="#other-commandssec"> other operations </a> . </p> <p> <strong> Components measured </strong> : Database </p> <h2 id="opssec"> Ops/sec </h2> <p> Number of total operations per second, which includes <a href="#readssec"> read operations </a> , <a href="#writessec"> write operations </a> , and <a href="#other-commandssec"> other operations </a> . </p> <p> <strong> Components measured </strong> : Cluster, Node, Database, and Shard </p> <h3 id="readssec"> Reads/sec </h3> <p> Number of total read operations per second. </p> <p> To find out which commands are read operations, run the following command with <a href="/docs/latest/operate/rs/references/cli-utilities/redis-cli/"> <code> redis-cli </code> </a> : </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">ACL CAT <span class="nb">read</span> </span></span></code></pre> </div> <p> <strong> Components measured </strong> : Database </p> <h3 id="writessec"> Writes/sec </h3> <p> Number of total write operations per second. </p> <p> To find out which commands are write operations, run the following command with <a href="/docs/latest/operate/rs/references/cli-utilities/redis-cli/"> <code> redis-cli </code> </a> : </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">ACL CAT write </span></span></code></pre> </div> <p> <strong> Components measured </strong> : Database </p> <h4 id="pending-writes-min"> Pending writes min </h4> <p> Minimum number of write operations queued per <a href="/docs/latest/operate/rs/databases/active-active/"> Active-Active </a> replica database. </p> <h4 id="pending-writes-max"> Pending writes max </h4> <p> Maximum number of write operations queued per <a href="/docs/latest/operate/rs/databases/active-active/"> Active-Active </a> replica database. </p> <h3 id="other-commandssec"> Other commands/sec </h3> <p> Number of operations per second that are not <a href="#readssec"> read operations </a> or <a href="#writessec"> write operations </a> . </p> <p> Examples of other operations include <a href="/docs/latest/commands/ping/"> PING </a> , [AUTH](/docs/latest/commands/auth/, and [INFO](/docs/latest/commands/info/ </p> <p> <strong> Components measured </strong> : Database </p> <h2 id="total-keys"> Total keys </h2> <p> Total number of keys in the dataset. </p> <p> Does not include replicated keys, even if <a href="/docs/latest/operate/rs/databases/durability-ha/replication/"> replication </a> is enabled. </p> <p> Total keys is not measured during <a href="/docs/latest/operate/rs/databases/configure/replica-ha/"> shard migration </a> . </p> <p> <strong> Components measured </strong> : Database </p> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/references/metrics/database-operations/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/cf.count.html
<section class="prose w-full py-12"> <h1 class="command-name"> CF.COUNT </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">CF.COUNT key item</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available in: </dt> <dd class="m-0"> <a href="/docs/stack"> Redis Stack </a> / <a href="/docs/data-types/probabilistic"> Bloom 1.0.0 </a> </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(k), where k is the number of sub-filters </dd> </dl> <p> Returns an estimation of the number of times a given item was added to a cuckoo filter. </p> <p> If you just want to check that a given item was added to a cuckoo filter, use <a href="/docs/latest/commands/cf.exists/"> <code> CF.EXISTS </code> </a> . </p> <h2 id="required-arguments"> Required arguments </h2> <details open=""> <summary> <code> key </code> </summary> <p> is key name for a cuckoo filter. </p> </details> <details open=""> <summary> <code> item </code> </summary> <p> is an item to check. </p> </details> <h2 id="return-value"> Return value </h2> <p> Returns one of these replies: </p> <ul> <li> <a href="/docs/latest/develop/reference/protocol-spec/#integers"> Integer reply </a> , where a positive value is an estimation of the number of times <code> item </code> was added to the filter. An overestimation is possible, but not an underestimation. <code> 0 </code> means that <code> key </code> does not exist or that <code> item </code> had not been added to the filter. See note in <a href="/docs/latest/commands/cf.del/"> <code> CF.DEL </code> </a> . </li> <li> [] on error (invalid arguments, wrong key type, etc.) </li> </ul> <h2 id="examples"> Examples </h2> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis&gt; CF.INSERT cf ITEMS item1 item2 item2 </span></span><span class="line"><span class="cl">1<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1</span> </span></span><span class="line"><span class="cl">2<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1</span> </span></span><span class="line"><span class="cl">3<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1</span> </span></span><span class="line"><span class="cl">redis&gt; CF.COUNT cf item1 </span></span><span class="line"><span class="cl"><span class="o">(</span>integer<span class="o">)</span> <span class="m">1</span> </span></span><span class="line"><span class="cl">redis&gt; CF.COUNT cf item2 </span></span><span class="line"><span class="cl"><span class="o">(</span>integer<span class="o">)</span> <span class="m">2</span></span></span></code></pre> </div> <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/cf.count/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/references/rest-api/objects/bdb/status/.html
<section class="prose w-full py-12 max-w-none"> <h1> BDB status field </h1> <p class="text-lg -mt-5 mb-10"> Documents the bdb status field used with Redis Enterprise Software REST API calls. </p> <p> The BDB status field is a read-only field that represents the database status. </p> <p> Possible status values: </p> <table> <thead> <tr> <th> Status </th> <th> Description </th> <th> Possible next status </th> </tr> </thead> <tbody> <tr> <td> 'active' </td> <td> Database is active and no special action is in progress </td> <td> 'active-change-pending' <br/> 'import-pending' <br/> 'delete-pending' </td> </tr> <tr> <td> 'active-change-pending' </td> <td> </td> <td> 'active' </td> </tr> <tr> <td> 'creation-failed' </td> <td> Initial database creation failed </td> <td> </td> </tr> <tr> <td> 'delete-pending' </td> <td> Database deletion is in progress </td> <td> </td> </tr> <tr> <td> 'import-pending' </td> <td> Dataset import is in progress </td> <td> 'active' </td> </tr> <tr> <td> 'pending' </td> <td> Temporary status during database creation </td> <td> 'active' <br/> 'creation-failed' </td> </tr> <tr> <td> 'recovery' </td> <td> Not currently relevant (intended for future use) </td> <td> </td> </tr> </tbody> </table> <a href="/docs/latest/images/rs/rest-api-bdb-status.png#no-click" sdata-lightbox="/images/rs/rest-api-bdb-status.png#no-click"> <img alt="BDB status" src="/docs/latest/images/rs/rest-api-bdb-status.png#no-click"/> </a> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/references/rest-api/objects/bdb/status/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/develop/reference/modules/modules-blocking-ops/.html
<section class="prose w-full py-12"> <h1> Redis modules and blocking commands </h1> <p class="text-lg -mt-5 mb-10"> How to implement blocking commands in a Redis module </p> <p> Redis has a few blocking commands among the built-in set of commands. One of the most used is <a href="/docs/latest/commands/blpop/"> <code> BLPOP </code> </a> (or the symmetric <a href="/docs/latest/commands/brpop/"> <code> BRPOP </code> </a> ) which blocks waiting for elements arriving in a list. </p> <p> The interesting fact about blocking commands is that they do not block the whole server, but just the client calling them. Usually the reason to block is that we expect some external event to happen: this can be some change in the Redis data structures like in the <a href="/docs/latest/commands/blpop/"> <code> BLPOP </code> </a> case, a long computation happening in a thread, to receive some data from the network, and so forth. </p> <p> Redis modules have the ability to implement blocking commands as well, this documentation shows how the API works and describes a few patterns that can be used in order to model blocking commands. </p> <h2 id="how-blocking-and-resuming-works"> How blocking and resuming works. </h2> <p> <em> Note: You may want to check the <code> helloblock.c </code> example in the Redis source tree inside the <code> src/modules </code> directory, for a simple to understand example on how the blocking API is applied. </em> </p> <p> In Redis modules, commands are implemented by callback functions that are invoked by the Redis core when the specific command is called by the user. Normally the callback terminates its execution sending some reply to the client. Using the following function instead, the function implementing the module command may request that the client is put into the blocked state: </p> <pre><code>RedisModuleBlockedClient *RedisModule_BlockClient(RedisModuleCtx *ctx, RedisModuleCmdFunc reply_callback, RedisModuleCmdFunc timeout_callback, void (*free_privdata)(void*), long long timeout_ms); </code></pre> <p> The function returns a <code> RedisModuleBlockedClient </code> object, which is later used in order to unblock the client. The arguments have the following meaning: </p> <ul> <li> <code> ctx </code> is the command execution context as usually in the rest of the API. </li> <li> <code> reply_callback </code> is the callback, having the same prototype of a normal command function, that is called when the client is unblocked in order to return a reply to the client. </li> <li> <code> timeout_callback </code> is the callback, having the same prototype of a normal command function that is called when the client reached the <code> ms </code> timeout. </li> <li> <code> free_privdata </code> is the callback that is called in order to free the private data. Private data is a pointer to some data that is passed between the API used to unblock the client, to the callback that will send the reply to the client. We'll see how this mechanism works later in this document. </li> <li> <code> ms </code> is the timeout in milliseconds. When the timeout is reached, the timeout callback is called and the client is automatically aborted. </li> </ul> <p> Once a client is blocked, it can be unblocked with the following API: </p> <pre><code>int RedisModule_UnblockClient(RedisModuleBlockedClient *bc, void *privdata); </code></pre> <p> The function takes as argument the blocked client object returned by the previous call to <code> RedisModule_BlockClient() </code> , and unblock the client. Immediately before the client gets unblocked, the <code> reply_callback </code> function specified when the client was blocked is called: this function will have access to the <code> privdata </code> pointer used here. </p> <p> IMPORTANT: The above function is thread safe, and can be called from within a thread doing some work in order to implement the command that blocked the client. </p> <p> The <code> privdata </code> data will be freed automatically using the <code> free_privdata </code> callback when the client is unblocked. This is useful <strong> since the reply callback may never be called </strong> in case the client timeouts or disconnects from the server, so it's important that it's up to an external function to have the responsibility to free the data passed if needed. </p> <p> To better understand how the API works, we can imagine writing a command that blocks a client for one second, and then send as reply "Hello!". </p> <p> Note: arity checks and other non important things are not implemented int his command, in order to take the example simple. </p> <pre><code>int Example_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { RedisModuleBlockedClient *bc = RedisModule_BlockClient(ctx,reply_func,timeout_func,NULL,0); pthread_t tid; pthread_create(&amp;tid,NULL,threadmain,bc); return REDISMODULE_OK; } void *threadmain(void *arg) { RedisModuleBlockedClient *bc = arg; sleep(1); /* Wait one second and unblock. */ RedisModule_UnblockClient(bc,NULL); } </code></pre> <p> The above command blocks the client ASAP, spawning a thread that will wait a second and will unblock the client. Let's check the reply and timeout callbacks, which are in our case very similar, since they just reply the client with a different reply type. </p> <pre><code>int reply_func(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { return RedisModule_ReplyWithSimpleString(ctx,"Hello!"); } int timeout_func(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { return RedisModule_ReplyWithNull(ctx); } </code></pre> <p> The reply callback just sends the "Hello!" string to the client. The important bit here is that the reply callback is called when the client is unblocked from the thread. </p> <p> The timeout command returns <code> NULL </code> , as it often happens with actual Redis blocking commands timing out. </p> <h2 id="passing-reply-data-when-unblocking"> Passing reply data when unblocking </h2> <p> The above example is simple to understand but lacks an important real world aspect of an actual blocking command implementation: often the reply function will need to know what to reply to the client, and this information is often provided as the client is unblocked. </p> <p> We could modify the above example so that the thread generates a random number after waiting one second. You can think at it as an actually expansive operation of some kind. Then this random number can be passed to the reply function so that we return it to the command caller. In order to make this working, we modify the functions as follow: </p> <pre><code>void *threadmain(void *arg) { RedisModuleBlockedClient *bc = arg; sleep(1); /* Wait one second and unblock. */ long *mynumber = RedisModule_Alloc(sizeof(long)); *mynumber = rand(); RedisModule_UnblockClient(bc,mynumber); } </code></pre> <p> As you can see, now the unblocking call is passing some private data, that is the <code> mynumber </code> pointer, to the reply callback. In order to obtain this private data, the reply callback will use the following function: </p> <pre><code>void *RedisModule_GetBlockedClientPrivateData(RedisModuleCtx *ctx); </code></pre> <p> So our reply callback is modified like that: </p> <pre><code>int reply_func(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { long *mynumber = RedisModule_GetBlockedClientPrivateData(ctx); /* IMPORTANT: don't free mynumber here, but in the * free privdata callback. */ return RedisModule_ReplyWithLongLong(ctx,mynumber); } </code></pre> <p> Note that we also need to pass a <code> free_privdata </code> function when blocking the client with <code> RedisModule_BlockClient() </code> , since the allocated long value must be freed. Our callback will look like the following: </p> <pre><code>void free_privdata(void *privdata) { RedisModule_Free(privdata); } </code></pre> <p> NOTE: It is important to stress that the private data is best freed in the <code> free_privdata </code> callback because the reply function may not be called if the client disconnects or timeout. </p> <p> Also note that the private data is also accessible from the timeout callback, always using the <code> GetBlockedClientPrivateData() </code> API. </p> <h2 id="aborting-the-blocking-of-a-client"> Aborting the blocking of a client </h2> <p> One problem that sometimes arises is that we need to allocate resources in order to implement the non blocking command. So we block the client, then, for example, try to create a thread, but the thread creation function returns an error. What to do in such a condition in order to recover? We don't want to take the client blocked, nor we want to call <code> UnblockClient() </code> because this will trigger the reply callback to be called. </p> <p> In this case the best thing to do is to use the following function: </p> <pre><code>int RedisModule_AbortBlock(RedisModuleBlockedClient *bc); </code></pre> <p> Practically this is how to use it: </p> <pre><code>int Example_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { RedisModuleBlockedClient *bc = RedisModule_BlockClient(ctx,reply_func,timeout_func,NULL,0); pthread_t tid; if (pthread_create(&amp;tid,NULL,threadmain,bc) != 0) { RedisModule_AbortBlock(bc); RedisModule_ReplyWithError(ctx,"Sorry can't create a thread"); } return REDISMODULE_OK; } </code></pre> <p> The client will be unblocked but the reply callback will not be called. </p> <h2 id="implementing-the-command-reply-and-timeout-callback-using-a-single-function"> Implementing the command, reply and timeout callback using a single function </h2> <p> The following functions can be used in order to implement the reply and callback with the same function that implements the primary command function: </p> <pre><code>int RedisModule_IsBlockedReplyRequest(RedisModuleCtx *ctx); int RedisModule_IsBlockedTimeoutRequest(RedisModuleCtx *ctx); </code></pre> <p> So I could rewrite the example command without using a separated reply and timeout callback: </p> <pre><code>int Example_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { if (RedisModule_IsBlockedReplyRequest(ctx)) { long *mynumber = RedisModule_GetBlockedClientPrivateData(ctx); return RedisModule_ReplyWithLongLong(ctx,mynumber); } else if (RedisModule_IsBlockedTimeoutRequest) { return RedisModule_ReplyWithNull(ctx); } RedisModuleBlockedClient *bc = RedisModule_BlockClient(ctx,reply_func,timeout_func,NULL,0); pthread_t tid; if (pthread_create(&amp;tid,NULL,threadmain,bc) != 0) { RedisModule_AbortBlock(bc); RedisModule_ReplyWithError(ctx,"Sorry can't create a thread"); } return REDISMODULE_OK; } </code></pre> <p> Functionally is the same but there are people that will prefer the less verbose implementation that concentrates most of the command logic in a single function. </p> <h2 id="working-on-copies-of-data-inside-a-thread"> Working on copies of data inside a thread </h2> <p> An interesting pattern in order to work with threads implementing the slow part of a command, is to work with a copy of the data, so that while some operation is performed in a key, the user continues to see the old version. However when the thread terminated its work, the representations are swapped and the new, processed version, is used. </p> <p> An example of this approach is the <a href="https://github.com/antirez/neural-redis"> Neural Redis module </a> where neural networks are trained in different threads while the user can still execute and inspect their older versions. </p> <h2 id="future-work"> Future work </h2> <p> An API is work in progress right now in order to allow Redis modules APIs to be called in a safe way from threads, so that the threaded command can access the data space and do incremental operations. </p> <p> There is no ETA for this feature but it may appear in the course of the Redis 4.0 release at some point. </p> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/develop/reference/modules/modules-blocking-ops/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/7.4/databases/import-export/flush/.html
<section class="prose w-full py-12 max-w-none"> <h1> Flush database data </h1> <p class="text-lg -mt-5 mb-10"> To delete the data in a database without deleting the database, you can use Redis CLI to flush it from the database. You can also use Redis CLI, the admin console, and the Redis Software REST API to flush data from Active-Active databases. </p> <p> To delete the data in a database without deleting the database configuration, you can flush the data from the database. </p> <p> You can use the Cluster Manager UI to flush data from Active-Active databases. </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Warning: </div> The flush command deletes ALL in-memory and persistence data in the database. We recommend that you <a href="/docs/latest/operate/rs/7.4/databases/import-export/schedule-backups/"> back up your database </a> before you flush the data. </div> </div> <h2 id="flush-data-from-a-database"> Flush data from a database </h2> <p> From the command line, you can flush a database with the redis-cli command or with your favorite Redis client. </p> <p> To flush data from a database with the redis-cli, run: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">redis-cli -h &lt;hostname&gt; -p &lt;portnumber&gt; -a &lt;password&gt; flushall </span></span></code></pre> </div> <p> Example: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">redis-cli -h redis-12345.cluster.local -p <span class="m">9443</span> -a xyz flushall </span></span></code></pre> </div> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> Port 9443 is the default <a href="/docs/latest/operate/rs/7.4/networking/port-configurations/#https://docs.redis.com/latest/rs/networking/port-configurations#ports-and-port-ranges-used-by-redis-enterprise-software"> port configuration </a> . </div> </div> <h2 id="flush-data-from-an-active-active-database"> Flush data from an Active-Active database </h2> <p> When you flush an Active-Active database (formerly known as CRDB), all of the replicas flush their data at the same time. </p> <p> To flush data from an Active-Active database: </p> <ul> <li> <p> Cluster Manager UI </p> <ol> <li> <p> If you are using the new Cluster Manager UI, switch to the legacy admin console. </p> <a href="/docs/latest/images/rs/screenshots/switch-to-legacy-ui.png" sdata-lightbox="/images/rs/screenshots/switch-to-legacy-ui.png"> <img alt="Select switch to legacy admin console from the dropdown." src="/docs/latest/images/rs/screenshots/switch-to-legacy-ui.png" width="300px"/> </a> </li> <li> <p> Go to <strong> database </strong> and select the Active-Active database that you want to flush. </p> </li> <li> <p> Go to <strong> configuration </strong> and click <strong> Flush </strong> at the bottom of the page. </p> </li> <li> <p> Enter the name of the Active-Active database to confirm that you want to flush the data. </p> </li> </ol> </li> <li> <p> Command line </p> <ol> <li> <p> To find the ID of the Active-Active database, run: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">crdb-cli crdb list </span></span></code></pre> </div> <p> For example: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ crdb-cli crdb list </span></span><span class="line"><span class="cl">CRDB-GUID NAME REPL-ID CLUSTER-FQDN </span></span><span class="line"><span class="cl">a16fe643-4a7b-4380-a5b2-96109d2e8bca crdb1 <span class="m">1</span> cluster1.local </span></span><span class="line"><span class="cl">a16fe643-4a7b-4380-a5b2-96109d2e8bca crdb1 <span class="m">2</span> cluster2.local </span></span><span class="line"><span class="cl">a16fe643-4a7b-4380-a5b2-96109d2e8bca crdb1 <span class="m">3</span> cluster3.local </span></span></code></pre> </div> </li> <li> <p> To flush the Active-Active database, run: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">crdb-cli crdb flush --crdb-guid &lt;CRDB-GUID&gt; </span></span></code></pre> </div> <p> The command output contains the task ID of the flush task, for example: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ crdb-cli crdb flush --crdb-guid a16fe643-4a7b-4380-a5b2-96109d2e8bca </span></span><span class="line"><span class="cl">Task 63239280-d060-4639-9bba-fc6a242c19fc created </span></span><span class="line"><span class="cl">---&gt; Status changed: queued -&gt; started </span></span></code></pre> </div> </li> <li> <p> To check the status of the flush task, run: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">crdb-cli task status --task-id &lt;Task-ID&gt; </span></span></code></pre> </div> <p> For example: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ crdb-cli task status --task-id 63239280-d060-4639-9bba-fc6a242c19fc </span></span><span class="line"><span class="cl">Task-ID: 63239280-d060-4639-9bba-fc6a242c19fc </span></span><span class="line"><span class="cl">CRDB-GUID: - </span></span><span class="line"><span class="cl">Status: finished </span></span></code></pre> </div> </li> </ol> </li> <li> <p> REST API </p> <ol> <li> <p> To find the ID of the Active-Active database, use <a href="/docs/latest/operate/rs/7.4/references/rest-api/requests/crdbs/#get-all-crdbs"> <code> GET /v1/crdbs </code> </a> : </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">GET https://<span class="o">[</span>host<span class="o">][</span>:port<span class="o">]</span>/v1/crdbs </span></span></code></pre> </div> </li> <li> <p> To flush the Active-Active database, use <a href="/docs/latest/operate/rs/7.4/references/rest-api/requests/crdbs/flush/#put-crdbs-flush"> <code> PUT /v1/crdbs/{guid}/flush </code> </a> : </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">PUT https://<span class="o">[</span>host<span class="o">][</span>:port<span class="o">]</span>/v1/crdbs/&lt;guid&gt;/flush </span></span></code></pre> </div> <p> The command output contains the task ID of the flush task. </p> </li> <li> <p> To check the status of the flush task, use <a href="/docs/latest/operate/rs/7.4/references/rest-api/requests/crdb_tasks/#get-crdb_task"> <code> GET /v1/crdb_tasks </code> </a> : </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">GET https://<span class="o">[</span>host<span class="o">][</span>:port<span class="o">]</span>/v1/crdb_tasks/&lt;task-id&gt; </span></span></code></pre> </div> </li> </ol> </li> </ul> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/databases/import-export/flush/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/oss_and_stack/management/debugging/.html
<section class="prose w-full py-12 max-w-none"> <h1> Debugging </h1> <p class="text-lg -mt-5 mb-10"> A guide to debugging Redis server processes </p> <p> Redis is developed with an emphasis on stability. We do our best with every release to make sure you'll experience a stable product with no crashes. However, if you ever need to debug the Redis process itself, read on. </p> <p> When Redis crashes, it produces a detailed report of what happened. However, sometimes looking at the crash report is not enough, nor is it possible for the Redis core team to reproduce the issue independently. In this scenario, we need help from the user who can reproduce the issue. </p> <p> This guide shows how to use GDB to provide the information the Redis developers will need to track the bug more easily. </p> <h2 id="what-is-gdb"> What is GDB? </h2> <p> GDB is the Gnu Debugger: a program that is able to inspect the internal state of another program. Usually tracking and fixing a bug is an exercise in gathering more information about the state of the program at the moment the bug happens, so GDB is an extremely useful tool. </p> <p> GDB can be used in two ways: </p> <ul> <li> It can attach to a running program and inspect the state of it at runtime. </li> <li> It can inspect the state of a program that already terminated using what is called a <em> core file </em> , that is, the image of the memory at the time the program was running. </li> </ul> <p> From the point of view of investigating Redis bugs we need to use both of these GDB modes. The user able to reproduce the bug attaches GDB to their running Redis instance, and when the crash happens, they create the <code> core </code> file that in turn the developer will use to inspect the Redis internals at the time of the crash. </p> <p> This way the developer can perform all the inspections in his or her computer without the help of the user, and the user is free to restart Redis in their production environment. </p> <h2 id="compiling-redis-without-optimizations"> Compiling Redis without optimizations </h2> <p> By default Redis is compiled with the <code> -O2 </code> switch, this means that compiler optimizations are enabled. This makes the Redis executable faster, but at the same time it makes Redis (like any other program) harder to inspect using GDB. </p> <p> It is better to attach GDB to Redis compiled without optimizations using the <code> make noopt </code> command (instead of just using the plain <code> make </code> command). However, if you have an already running Redis in production there is no need to recompile and restart it if this is going to create problems on your side. GDB still works against executables compiled with optimizations. </p> <p> You should not be overly concerned at the loss of performance from compiling Redis without optimizations. It is unlikely that this will cause problems in your environment as Redis is not very CPU-bound. </p> <h2 id="attaching-gdb-to-a-running-process"> Attaching GDB to a running process </h2> <p> If you have an already running Redis server, you can attach GDB to it, so that if Redis crashes it will be possible to both inspect the internals and generate a <code> core dump </code> file. </p> <p> After you attach GDB to the Redis process it will continue running as usual without any loss of performance, so this is not a dangerous procedure. </p> <p> In order to attach GDB the first thing you need is the <em> process ID </em> of the running Redis instance (the <em> pid </em> of the process). You can easily obtain it using <code> redis-cli </code> : </p> <pre><code>$ redis-cli info | grep process_id process_id:58414 </code></pre> <p> In the above example the process ID is <strong> 58414 </strong> . </p> <p> Login into your Redis server. </p> <p> (Optional but recommended) Start <strong> screen </strong> or <strong> tmux </strong> or any other program that will make sure that your GDB session will not be closed if your ssh connection times out. You can learn more about screen in <a href="http://www.linuxjournal.com/article/6340"> this article </a> . </p> <p> Attach GDB to the running Redis server by typing: </p> <pre><code>$ gdb &lt;path-to-redis-executable&gt; &lt;pid&gt; </code></pre> <p> For example: </p> <pre><code>$ gdb /usr/local/bin/redis-server 58414 </code></pre> <p> GDB will start and will attach to the running server printing something like the following: </p> <pre><code>Reading symbols for shared libraries + done 0x00007fff8d4797e6 in epoll_wait () (gdb) </code></pre> <p> At this point GDB is attached but <strong> your Redis instance is blocked by GDB </strong> . In order to let the Redis instance continue the execution just type <strong> continue </strong> at the GDB prompt, and press enter. </p> <pre><code>(gdb) continue Continuing. </code></pre> <p> Done! Now your Redis instance has GDB attached. Now you can wait for the next crash. :) </p> <p> Now it's time to detach your screen/tmux session, if you are running GDB using it, by pressing <strong> Ctrl-a a </strong> key combination. </p> <h2 id="after-the-crash"> After the crash </h2> <p> Redis has a command to simulate a segmentation fault (in other words a bad crash) using the <code> DEBUG SEGFAULT </code> command (don't use it against a real production instance of course! So I'll use this command to crash my instance to show what happens in the GDB side: </p> <pre><code>(gdb) continue Continuing. Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_INVALID_ADDRESS at address: 0xffffffffffffffff debugCommand (c=0x7ffc32005000) at debug.c:220 220 *((char*)-1) = 'x'; </code></pre> <p> As you can see GDB detected that Redis crashed, and was even able to show me the file name and line number causing the crash. This is already much better than the Redis crash report back trace (containing just function names and binary offsets). </p> <h2 id="obtaining-the-stack-trace"> Obtaining the stack trace </h2> <p> The first thing to do is to obtain a full stack trace with GDB. This is as simple as using the <strong> bt </strong> command: </p> <pre><code>(gdb) bt #0 debugCommand (c=0x7ffc32005000) at debug.c:220 #1 0x000000010d246d63 in call (c=0x7ffc32005000) at redis.c:1163 #2 0x000000010d247290 in processCommand (c=0x7ffc32005000) at redis.c:1305 #3 0x000000010d251660 in processInputBuffer (c=0x7ffc32005000) at networking.c:959 #4 0x000000010d251872 in readQueryFromClient (el=0x0, fd=5, privdata=0x7fff76f1c0b0, mask=220924512) at networking.c:1021 #5 0x000000010d243523 in aeProcessEvents (eventLoop=0x7fff6ce408d0, flags=220829559) at ae.c:352 #6 0x000000010d24373b in aeMain (eventLoop=0x10d429ef0) at ae.c:397 #7 0x000000010d2494ff in main (argc=1, argv=0x10d2b2900) at redis.c:2046 </code></pre> <p> This shows the backtrace, but we also want to dump the processor registers using the <strong> info registers </strong> command: </p> <pre><code>(gdb) info registers rax 0x0 0 rbx 0x7ffc32005000 140721147367424 rcx 0x10d2b0a60 4515891808 rdx 0x7fff76f1c0b0 140735188943024 rsi 0x10d299777 4515796855 rdi 0x0 0 rbp 0x7fff6ce40730 0x7fff6ce40730 rsp 0x7fff6ce40650 0x7fff6ce40650 r8 0x4f26b3f7 1327936503 r9 0x7fff6ce40718 140735020271384 r10 0x81 129 r11 0x10d430398 4517462936 r12 0x4b7c04f8babc0 1327936503000000 r13 0x10d3350a0 4516434080 r14 0x10d42d9f0 4517452272 r15 0x10d430398 4517462936 rip 0x10d26cfd4 0x10d26cfd4 &lt;debugCommand+68&gt; eflags 0x10246 66118 cs 0x2b 43 ss 0x0 0 ds 0x0 0 es 0x0 0 fs 0x0 0 gs 0x0 0 </code></pre> <p> Please <strong> make sure to include </strong> both of these outputs in your bug report. </p> <h2 id="obtaining-the-core-file"> Obtaining the core file </h2> <p> The next step is to generate the core dump, that is the image of the memory of the running Redis process. This is done using the <code> gcore </code> command: </p> <pre><code>(gdb) gcore Saved corefile core.58414 </code></pre> <p> Now you have the core dump to send to the Redis developer, but <strong> it is important to understand </strong> that this happens to contain all the data that was inside the Redis instance at the time of the crash; Redis developers will make sure not to share the content with anyone else, and will delete the file as soon as it is no longer used for debugging purposes, but you are warned that by sending the core file you are sending your data. </p> <h2 id="what-to-send-to-developers"> What to send to developers </h2> <p> Finally you can send everything to the Redis core team: </p> <ul> <li> The Redis executable you are using. </li> <li> The stack trace produced by the <strong> bt </strong> command, and the registers dump. </li> <li> The core file you generated with gdb. </li> <li> Information about the operating system and GCC version, and Redis version you are using. </li> </ul> <h2 id="thank-you"> Thank you </h2> <p> Your help is extremely important! Many issues can only be tracked this way. So thanks! </p> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/oss_and_stack/management/debugging/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/references/rest-api/requests/bdbs/syncer_state/crdt/.html
<section class="prose w-full py-12 max-w-none"> <h1> CRDT syncer state requests </h1> <p class="text-lg -mt-5 mb-10"> CRDT syncer state requests </p> <table> <thead> <tr> <th> Method </th> <th> Path </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="#get-syncer-state"> GET </a> </td> <td> <code> /v1/bdbs/{uid}/syncer_state/crdt </code> </td> <td> Get a CRDB's syncer state </td> </tr> </tbody> </table> <h2 id="get-syncer-state"> Get CRDB syncer state </h2> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">GET /v1/bdbs/<span class="o">{</span>int: uid<span class="o">}</span>/syncer_state/crdt </span></span></code></pre> </div> <p> Get a CRDB's syncer state as JSON. </p> <h3 id="permissions"> Permissions </h3> <table> <thead> <tr> <th> Permission name </th> <th> Roles </th> </tr> </thead> <tbody> <tr> <td> <a href="/docs/latest/operate/rs/references/rest-api/permissions/#view_bdb_info"> view_bdb_info </a> </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> db_viewer <br/> user_manager </td> </tr> </tbody> </table> <h3 id="get-request"> Request </h3> <h4 id="example-http-request"> Example HTTP request </h4> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">GET /v1/bdbs/1/syncer_state/crdt </span></span></code></pre> </div> <h4 id="headers"> Headers </h4> <table> <thead> <tr> <th> Key </th> <th> Value </th> </tr> </thead> <tbody> <tr> <td> Host </td> <td> The domain name or IP of the cluster. </td> </tr> <tr> <td> Accept </td> <td> application/json </td> </tr> </tbody> </table> <h4 id="url-parameters"> URL parameters </h4> <table> <thead> <tr> <th> Field </th> <th> Type </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> uid </td> <td> integer </td> <td> The unique ID of the database requested. </td> </tr> </tbody> </table> <h3 id="get-response"> Response </h3> <p> Returns a JSON object that represents the syncer state. </p> <h4 id="example-json-body"> Example JSON body </h4> <div class="highlight"> <pre class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"DB"</span><span class="p">:</span> <span class="mi">22</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"RunID"</span><span class="p">:</span> <span class="mi">1584086516</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="c1">// additional fields... </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="p">}</span> </span></span></code></pre> </div> <h4 id="get-status-codes"> Status codes </h4> <table> <thead> <tr> <th> Code </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1"> 200 OK </a> </td> <td> OK </td> </tr> <tr> <td> <a href="https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5"> 404 Not Found </a> </td> <td> Syncer state key does not exist </td> </tr> <tr> <td> <a href="https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.1"> 500 Internal Server Error </a> </td> <td> Internal error </td> </tr> <tr> <td> <a href="https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.4"> 503 Service Unavailable </a> </td> <td> Redis connection error, service unavailable </td> </tr> </tbody> </table> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/references/rest-api/requests/bdbs/syncer_state/crdt/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/references/cli-utilities/crdb-cli/crdb/delete/.html
<section class="prose w-full py-12 max-w-none"> <h1> crdb-cli crdb delete </h1> <p class="text-lg -mt-5 mb-10"> Deletes an Active-Active database. </p> <p> Deletes an Active-Active database. </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">crdb-cli crdb delete --crdb-guid &lt;guid&gt; </span></span><span class="line"><span class="cl"> <span class="o">[</span> --no-wait <span class="o">]</span> </span></span></code></pre> </div> <p> This command is irreversible. If the data in your database is important, back it up before you delete the database. </p> <h3 id="parameters"> Parameters </h3> <table> <thead> <tr> <th> Parameter </th> <th> Value </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> crdb-guid </td> <td> string </td> <td> The GUID of the database (required) </td> </tr> <tr> <td> no-wait </td> <td> </td> <td> Does not wait for the task to complete </td> </tr> </tbody> </table> <h3 id="returns"> Returns </h3> <p> Returns the task ID of the task that is deleting the database. </p> <p> If <code> --no-wait </code> is specified, the command exits. Otherwise, it will wait for the database to be deleted and return <code> finished </code> . </p> <h3 id="example"> Example </h3> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ crdb-cli crdb delete --crdb-guid db6365b5-8aca-4055-95d8-7eb0105c0b35 </span></span><span class="line"><span class="cl">Task dfe6cacc-88ff-4667-812e-938fd05fe359 created </span></span><span class="line"><span class="cl"> ---&gt; Status changed: queued -&gt; started </span></span><span class="line"><span class="cl"> ---&gt; Status changed: started -&gt; finished </span></span></code></pre> </div> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/references/cli-utilities/crdb-cli/crdb/delete/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rc/changelog/.html
<section class="prose w-full py-12 max-w-none"> <h1> Redis Cloud changelog </h1> <p class="text-lg -mt-5 mb-10"> Lists new features, enhancements, and other changes in Redis Cloud. </p> <p> Changelogs list new features, enhancements, and other changes in Redis Cloud. </p> <p> Select a month from the following table to see a more detailed changelog for that month: </p> <table> <thead> <tr> <th style="text-align:left"> Month </th> <th style="text-align:left"> Major changes </th> </tr> </thead> <tbody> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rc/changelog/october-2024/"> October 2024 </a> </td> <td style="text-align:left"> Redis 7.4 Preview on Redis Cloud Pro, Security fixes </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rc/changelog/july-2024/"> July 2024 </a> </td> <td style="text-align:left"> Redis 7.4 Preview </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rc/changelog/june-2024/"> June 2024 </a> </td> <td style="text-align:left"> Redis Cloud Essentials support for Terraform </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rc/changelog/may-2024/"> May 2024 </a> </td> <td style="text-align:left"> Multi-domain SAML setup, SAML domain verification, Active-Active search support </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rc/changelog/april-2024/"> April 2024 </a> </td> <td style="text-align:left"> Nano billing unit, Essentials subscriptions through AWS Marketplace </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rc/changelog/march-2024/"> March 2024 </a> </td> <td style="text-align:left"> Fixed plans through Google Cloud Marketplace </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rc/changelog/february-2024/"> February 2024 </a> </td> <td style="text-align:left"> CIDR overlap detection </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rc/changelog/january-2024/"> January 2024 </a> </td> <td style="text-align:left"> Transit Gateway, Database tags </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rc/changelog/2023/"> 2023 </a> </td> <td style="text-align:left"> All Redis Cloud changelogs from 2023. </td> </tr> </tbody> </table> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rc/changelog/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/blmove/.html
<section class="prose w-full py-12"> <h1 class="command-name"> BLMOVE </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">BLMOVE source destination &lt;LEFT | RIGHT&gt; &lt;LEFT | RIGHT&gt; timeout</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available since: </dt> <dd class="m-0"> 6.2.0 </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(1) </dd> <dt class="font-semibold text-redis-ink-900 m-0"> ACL categories: </dt> <dd class="m-0"> <code> @write </code> <span class="mr-1 last:hidden"> , </span> <code> @list </code> <span class="mr-1 last:hidden"> , </span> <code> @slow </code> <span class="mr-1 last:hidden"> , </span> <code> @blocking </code> <span class="mr-1 last:hidden"> , </span> </dd> </dl> <p> <code> BLMOVE </code> is the blocking variant of <a href="/docs/latest/commands/lmove/"> <code> LMOVE </code> </a> . When <code> source </code> contains elements, this command behaves exactly like <a href="/docs/latest/commands/lmove/"> <code> LMOVE </code> </a> . When used inside a <a href="/docs/latest/commands/multi/"> <code> MULTI </code> </a> / <a href="/docs/latest/commands/exec/"> <code> EXEC </code> </a> block, this command behaves exactly like <a href="/docs/latest/commands/lmove/"> <code> LMOVE </code> </a> . When <code> source </code> is empty, Redis will block the connection until another client pushes to it or until <code> timeout </code> (a double value specifying the maximum number of seconds to block) is reached. A <code> timeout </code> of zero can be used to block indefinitely. </p> <p> This command comes in place of the now deprecated <a href="/docs/latest/commands/brpoplpush/"> <code> BRPOPLPUSH </code> </a> . Doing <code> BLMOVE RIGHT LEFT </code> is equivalent. </p> <p> See <a href="/docs/latest/commands/lmove/"> <code> LMOVE </code> </a> for more information. </p> <h2 id="pattern-reliable-queue"> Pattern: Reliable queue </h2> <p> Please see the pattern description in the <a href="/docs/latest/commands/lmove/"> <code> LMOVE </code> </a> documentation. </p> <h2 id="pattern-circular-list"> Pattern: Circular list </h2> <p> Please see the pattern description in the <a href="/docs/latest/commands/lmove/"> <code> LMOVE </code> </a> documentation. </p> <h2 id="resp2-reply"> RESP2 Reply </h2> <p> One of the following: </p> <ul> <li> <a href="../../develop/reference/protocol-spec#bulk-strings"> Bulk string reply </a> : the element being popped from the <em> source </em> and pushed to the <em> destination </em> . </li> <li> <a href="../../develop/reference/protocol-spec#bulk-strings"> Nil reply </a> : the operation timed-out </li> </ul> <h2 id="resp3-reply"> RESP3 Reply </h2> <p> One of the following: </p> <ul> <li> <a href="../../develop/reference/protocol-spec#bulk-strings"> Bulk string reply </a> : the element being popped from the <em> source </em> and pushed to the <em> destination </em> . </li> <li> <a href="../../develop/reference/protocol-spec#nulls"> Null reply </a> : the operation timed-out </li> </ul> <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/blmove/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/7.4/references/client_references/.html
<section class="prose w-full py-12 max-w-none"> <h1> Develop with Redis clients </h1> <p class="text-lg -mt-5 mb-10"> Redis client libraries allow you to connect to Redis instances from within your application. This section provides an overview of several recommended Redis clients for popular programming and scripting languages. </p> <p> To connect to Redis instances from within your application, use a Redis client library that matches your application's language. </p> <h2 id="official-clients"> Official clients </h2> <table> <thead> <tr> <th style="text-align:left"> Language </th> <th style="text-align:left"> Client name </th> </tr> </thead> <tbody> <tr> <td style="text-align:left"> .Net </td> <td style="text-align:left"> <a href="/docs/latest/develop/clients/dotnet/"> NRedisStack </a> </td> </tr> <tr> <td style="text-align:left"> Go </td> <td style="text-align:left"> <a href="/docs/latest/develop/clients/go/"> go-redis </a> </td> </tr> <tr> <td style="text-align:left"> Java </td> <td style="text-align:left"> <a href="/docs/latest/develop/clients/jedis/"> Jedis </a> (Synchronous) and <a href="/docs/latest/develop/clients/lettuce/"> Lettuce </a> (Asynchronous) </td> </tr> <tr> <td style="text-align:left"> Node.js </td> <td style="text-align:left"> <a href="/docs/latest/develop/clients/nodejs/"> node-redis </a> </td> </tr> <tr> <td style="text-align:left"> Python </td> <td style="text-align:left"> <a href="/docs/latest/develop/clients/redis-py/"> redis-py </a> </td> </tr> </tbody> </table> <p> Select a client name to see its quick start. </p> <h2 id="other-clients"> Other clients </h2> <p> For a list of community-driven Redis clients, which are available for more programming languages, see <a href="/docs/latest/develop/clients/#community-supported-clients"> Community-supported clients </a> . </p> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/references/client_references/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/kubernetes/recommendations/persistent-volumes/.html
<section class="prose w-full py-12 max-w-none"> <h1> Use persistent volumes in Redis Enterprise clusters </h1> <p class="text-lg -mt-5 mb-10"> This section covers details about how persistent volumes are sized and specified for Redis Enterprise cluster deployments. </p> <h2 id="storage-types"> Storage types </h2> <p> Redis Enterprise for Kubernetes can only use storage classes supported by block storage. Block storage is mounted at the Kubernetes node level and utilizes EXT4 or XFS file systems. It can be sourced from enterprise-grade SANs or cloud environments such as EBS, Azure Managed Disks, or GCP persistent disks. </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Warning: </div> NFS, NFS-like, and multi-read-write/shared storage options are not supported. These types of storage are often slow and can cause locking behaviors that are incompatible with the requirements of database storage. </div> </div> <h2 id="rec-persistentspec-field"> REC <code> persistentSpec </code> field </h2> <p> To deploy a Redis Enterprise cluster with Redis Enterprise operator the spec should include a <em> persistentSpec </em> section, in the <em> redis-enterprise-cluster.yaml </em> file: </p> <pre><code>spec: nodes: 3 persistentSpec: enabled: true storageClassName: "standard" volumeSize: "23Gi” #optional </code></pre> <p> Persistence storage is a requirement for production deployments. </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> For <strong> production deployments </strong> of Redis Enterprise Cluster on Kubernetes, the Redis Enterprise Cluster (REC) must be deployed with persistence enabled. The REC deployment files in the <a href="https://github.com/RedisLabs/redis-enterprise-k8s-docs"> Kubernetes documentation </a> contain this declaration by default. </div> </div> <h2 id="volume-size"> Volume size </h2> <p> <em> volumeSize </em> is an optional definition. By default, if the definition is omitted, operator allocates five times (5x) the amount of memory (RAM) defined for nodes (see example below), which is the recommended persistent storage size as described in the <a href="/docs/latest/operate/rs/installing-upgrading/install/plan-deployment/hardware-requirements/"> Hardware requirements </a> article. </p> <p> To explicitly specify the persistent storage size, use the <em> volumeSize </em> property as described in the example above. </p> <p> Persistent volume claims can be expanded, but not reduced after creation. See <a href="/docs/latest/operate/kubernetes/re-clusters/expand-pvc/"> Expand PersistentVolumeClaim (PVC) </a> for details. </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> We recommend that you omit the volumeSize definition from the REC declaration so that the Redis Enterprise Cluster deployment on Kubernetes use the default volume size. </div> </div> <h2 id="storage-class-name"> Storage class name </h2> <p> <em> storageClassName </em> determines the Storage Class resource, which is defined by the Kubernetes cluster administrator, to be used for persistent storage. </p> <p> Different Kubernetes distributions and different deployments use different Storage Class resources. </p> <p> In order to determine the Storage Class resources available for your K8s deployment, use the following command: </p> <pre><code>kubectl get StorageClass </code></pre> <p> Typically, AWS provides “gp2” as the Storage Class name while GKE uses “standard.” Azure provides two Storage Classes: "default" using HDDs, and "managed-premium" using SSDs. </p> <p> Below is an example of a response to the command. </p> <table> <thead> <tr> <th> </th> <th> </th> </tr> </thead> <tbody> <tr> <td> <em> Name: </em> </td> <td> <em> gp2 </em> </td> </tr> <tr> <td> <em> IsDefaultClass: </em> </td> <td> <em> Yes </em> </td> </tr> <tr> <td> <em> Annotations: </em> </td> <td> <em> storageclass.beta.kubernetes.io/is-default-class=true </em> </td> </tr> <tr> <td> <em> Provisioner: </em> </td> <td> <em> kubernetes.io/aws-ebs </em> </td> </tr> <tr> <td> <em> Parameters: </em> </td> <td> <em> encrypted=false,kmsKeyId=,type=gp2 </em> </td> </tr> <tr> <td> <em> AllowVolumeExpansion: </em> </td> <td> <em> &lt;unset&gt; </em> </td> </tr> <tr> <td> <em> MountOptions: </em> </td> <td> <em> &lt;none&gt; </em> </td> </tr> <tr> <td> <em> ReclaimPolicy: </em> </td> <td> <em> Delete </em> </td> </tr> <tr> <td> <em> VolumeBindingMode: </em> </td> <td> <em> Immediate </em> </td> </tr> <tr> <td> <em> Events: </em> </td> <td> <em> &lt;none&gt; </em> </td> </tr> </tbody> </table> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> storageClassName must be specified for this deployment type. </div> </div> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Warning: </div> The storage class cannot be changed after deployment. Trying to change this value after deployment could result in unexpected and potentially damaging behavior. </div> </div> <p> Example of the redisEnterpriseNodeResources definition: </p> <pre><code>redisEnterpriseNodeResources: limits: cpu: “4000m” memory: 4Gi requests: cpu: “4000m” memory: 4Gi </code></pre> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/kubernetes/recommendations/persistent-volumes/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/ts.createrule/.html
<section class="prose w-full py-12"> <h1 class="command-name"> TS.CREATERULE </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">TS.CREATERULE sourceKey destKey AGGREGATION aggregator bucketDuration [alignTimestamp] </pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available in: </dt> <dd class="m-0"> <a href="/docs/stack"> Redis Stack </a> / <a href="/docs/data-types/timeseries"> TimeSeries 1.0.0 </a> </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(1) </dd> </dl> <p> Create a compaction rule </p> <p> <a href="#examples"> Examples </a> </p> <h2 id="required-arguments"> Required arguments </h2> <details open=""> <summary> <code> sourceKey </code> </summary> <p> is key name for the source time series. </p> </details> <details open=""> <summary> <code> destKey </code> </summary> <p> is key name for destination (compacted) time series. It must be created before <code> TS.CREATERULE </code> is called. </p> </details> <details open=""> <summary> <code> AGGREGATION aggregator bucketDuration </code> </summary> <p> aggregates results into time buckets. </p> <ul> <li> <p> <code> aggregator </code> takes one of the following aggregation types: </p> <table> <thead> <tr> <th> <code> aggregator </code> </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <code> avg </code> </td> <td> Arithmetic mean of all values </td> </tr> <tr> <td> <code> sum </code> </td> <td> Sum of all values </td> </tr> <tr> <td> <code> min </code> </td> <td> Minimum value </td> </tr> <tr> <td> <code> max </code> </td> <td> Maximum value </td> </tr> <tr> <td> <code> range </code> </td> <td> Difference between the highest and the lowest value </td> </tr> <tr> <td> <code> count </code> </td> <td> Number of values </td> </tr> <tr> <td> <code> first </code> </td> <td> Value with lowest timestamp in the bucket </td> </tr> <tr> <td> <code> last </code> </td> <td> Value with highest timestamp in the bucket </td> </tr> <tr> <td> <code> std.p </code> </td> <td> Population standard deviation of the values </td> </tr> <tr> <td> <code> std.s </code> </td> <td> Sample standard deviation of the values </td> </tr> <tr> <td> <code> var.p </code> </td> <td> Population variance of the values </td> </tr> <tr> <td> <code> var.s </code> </td> <td> Sample variance of the values </td> </tr> <tr> <td> <code> twa </code> </td> <td> Time-weighted average over the bucket's timeframe (since RedisTimeSeries v1.8) </td> </tr> </tbody> </table> </li> <li> <p> <code> bucketDuration </code> is duration of each bucket, in milliseconds. </p> </li> </ul> <p> <note> <b> Notes </b> </note> </p> <ul> <li> Only new samples that are added into the source series after the creation of the rule will be aggregated. </li> <li> Calling <code> TS.CREATERULE </code> with a nonempty <code> destKey </code> may result in inconsistencies between the raw and the compacted data. </li> <li> Explicitly adding samples to a compacted time series (using <a href="/docs/latest/commands/ts.add/"> <code> TS.ADD </code> </a> , <a href="/docs/latest/commands/ts.madd/"> <code> TS.MADD </code> </a> , <a href="/docs/latest/commands/ts.incrby/"> <code> TS.INCRBY </code> </a> , or <a href="/docs/latest/commands/ts.decrby/"> <code> TS.DECRBY </code> </a> ) may result in inconsistencies between the raw and the compacted data. The compaction process may override such samples. </li> <li> If no samples are added to the source time series during a bucket period. no <em> compacted sample </em> is added to the destination time series. </li> <li> The timestamp of a compacted sample added to the destination time series is set to the start timestamp the appropriate compaction bucket. For example, for a 10-minute compaction bucket with no alignment, the compacted samples timestamps are <code> x:00 </code> , <code> x:10 </code> , <code> x:20 </code> , and so on. </li> <li> Deleting <code> destKey </code> will cause the compaction rule to be deleted as well. </li> </ul> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Warning: </div> On a clustered environment, you must use <a href="/docs/latest/operate/oss_and_stack/reference/cluster-spec/#hash-tags"> hash tags </a> to force <code> sourceKey </code> and <code> destKey </code> to be stored in the same hash slot. </div> </div> <h2 id="optional-arguments"> Optional arguments </h2> <details open=""> <summary> <code> alignTimestamp </code> (since RedisTimeSeries v1.8) </summary> <p> ensures that there is a bucket that starts exactly at <code> alignTimestamp </code> and aligns all other buckets accordingly. It is expressed in milliseconds. The default value is 0: aligned with the Unix epoch. </p> <p> For example, if <code> bucketDuration </code> is 24 hours ( <code> 24 * 3600 * 1000 </code> ), setting <code> alignTimestamp </code> to 6 hours after the Unix epoch ( <code> 6 * 3600 * 1000 </code> ) ensures that each bucket’s timeframe is <code> [06:00 .. 06:00) </code> . </p> </details> <h2 id="return-value"> Return value </h2> <p> Returns one of these replies: </p> <ul> <li> <a href="/docs/latest/develop/reference/protocol-spec/#simple-strings"> Simple string reply </a> - <code> OK </code> if executed correctly </li> <li> [] on error (invalid arguments, wrong key type, etc.), when <code> sourceKey </code> does not exist, when <code> destKey </code> does not exist, when <code> sourceKey </code> is already a destination of a compaction rule, when <code> destKey </code> is already a source or a destination of a compaction rule, or when <code> sourceKey </code> and <code> destKey </code> are identical </li> </ul> <h2 id="examples"> Examples </h2> <details open=""> <summary> <b> Create a compaction rule </b> </summary> <p> Create a time series to store the temperatures measured in Tel Aviv. </p> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">127.0.0.1:6379&gt; TS.CREATE temp:TLV LABELS <span class="nb">type</span> temp location TLV </span></span><span class="line"><span class="cl">OK</span></span></code></pre> </div> <p> Next, create a compacted time series named <em> dailyAvgTemp </em> containing one compacted sample per 24 hours: the time-weighted average of all measurements taken from midnight to next midnight. </p> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">127.0.0.1:6379&gt; TS.CREATE dailyAvgTemp:TLV LABELS <span class="nb">type</span> temp location TLV </span></span><span class="line"><span class="cl">127.0.0.1:6379&gt; TS.CREATERULE temp:TLV dailyAvgTemp:TLV AGGREGATION twa <span class="m">86400000</span> </span></span></code></pre> </div> <p> Now, also create a compacted time series named <em> dailyDiffTemp </em> . This time series will contain one compacted sample per 24 hours: the difference between the minimum and the maximum temperature measured between 06:00 and 06:00 next day. Here, 86400000 is the number of milliseconds in 24 hours, 21600000 is the number of milliseconds in 6 hours. </p> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">127.0.0.1:6379&gt; TS.CREATE dailyDiffTemp:TLV LABELS <span class="nb">type</span> temp location TLV </span></span><span class="line"><span class="cl">127.0.0.1:6379&gt; TS.CREATERULE temp:TLV dailyDiffTemp:TLV AGGREGATION range <span class="m">86400000</span> <span class="m">21600000</span></span></span></code></pre> </div> </details> <h2 id="see-also"> See also </h2> <p> <a href="/docs/latest/commands/ts.deleterule/"> <code> TS.DELETERULE </code> </a> </p> <h2 id="related-topics"> Related topics </h2> <p> <a href="/docs/latest/develop/data-types/timeseries/"> RedisTimeSeries </a> </p> <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/ts.createrule/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </details> </section>
https://redis.io/docs/latest/operate/rs/release-notes/legacy-release-notes/rs-5-4-14-february-2020/.html
<section class="prose w-full py-12 max-w-none"> <h1> Redis Enterprise Software Release Notes 5.4.14 (February 2020) </h1> <p> <a href="https://redislabs.com/redis-enterprise/software/downloads/#downloads"> Redis Enterprise Software (RS) 5.4.14 </a> is now available. This release bundles OSS Redis 5.0.7 and includes new Redis Modules versions, several enhancements, and bug fixes. </p> <h2 id="overview"> Overview </h2> <p> Follow these <a href="/docs/latest/operate/rs/installing-upgrading/upgrading/"> instructions </a> for upgrading to RS 5.4.14 from RS 5.0.2 and above. </p> <h2 id="new-features"> New features </h2> <ul> <li> Version <a href="https://raw.githubusercontent.com/antirez/redis/5.0/00-RELEASENOTES"> 5.0.7 </a> of OSS Redis is merged into RS 5.4.14. </li> <li> The following GA releases of Redis Modules are bundled in RS 5.4.14: <ul> <li> <a href="https://redislabs.com/redis-enterprise/redis-bloom/"> RedisBloom </a> , version 2.2.1 (updated, <a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/redisbloom/redisbloom-2.2-release-notes.md#redisbloom-221-january-2020"> release notes </a> ) </li> <li> <a href="https://redislabs.com/redis-enterprise/redis-graph/"> RedisGraph </a> , version 2.0.1 (updated, <a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/redisgraph/redisgraph-2.0-release-notes.md#redisgraph-20-ga-201---january-2020"> release notes </a> ) </li> <li> <a href="https://redislabs.com/redis-enterprise/redis-json/"> RedisJSON </a> , version 1.0.4 (update, <a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/redisjson/redisjson-1.0-release-notes"> release notes </a> ) </li> <li> <a href="https://redislabs.com/redis-enterprise/redis-search/"> RediSearch </a> , version 1.4.25 (updated, <a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/redisearch/redisearch-1.4-release-notes.md#redisearch-1425-march-2020"> release notes </a> ) </li> <li> <a href="https://redislabs.com/redis-enterprise/redis-time-series/"> RedisTimeSeries </a> , version 1.2.3 (updated, <a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/redistimeseries/redistimeseries-1.2-release-notes"> release notes </a> ) </li> </ul> </li> </ul> <h2 id="additional-capabilities"> Additional capabilities </h2> <ul> <li> <p> Added the ability to retrieve license details with a REST API command. Now you can get your license details from the admin console (settings &gt; general) or from the REST API command: </p> <p> <code> GET https://localhost:9443/v1/license </code> </p> <p> The REST API response includes: </p> <ul> <li> license - The cluster’s name (FQDN) in the key string </li> <li> expired - If the cluster key is expired (True or False) </li> <li> activation_date - The date of the cluster key activation </li> <li> expiration_date - The date of the cluster key expiration </li> <li> shards_limit - The number of shards allowed by the cluster key </li> </ul> </li> <li> <p> Added Flush command in the UI console for Active-Active databases. The command flushes the data from all participating clusters. </p> </li> <li> <p> Updated <code> rladmin upgrade module </code> command so module arguments are optional. When you upgrade the module for a database, you can either: </p> <ul> <li> Specify the module arguments to replace the existing arguments </li> <li> Specify the <code> keep_module_args </code> flag to use the existing arguments </li> </ul> <p> Examples: </p> <ol> <li> <p> To upgrade the version of RediSearch to 10017 and replace the module arguments: </p> <p> <code> rladmin upgrade module db_name MyAwesomeDB module_name ft version 10017 module_args "PARTITIONS AUTO" </code> </p> </li> <li> <p> To upgrade RedisBloom to version 10100 and remove the current module arguments: </p> <p> <code> rladmin upgrade module db_name MyDB module_name bf version 10100 module_args " " </code> </p> </li> <li> <p> To upgrade RedisJSON to 10002 and use the current module arguments: </p> <p> <code> rladmin upgrade module db_name MyDB module_name ReJSON version 10002 keep_module_args </code> </p> </li> </ol> </li> <li> <p> Upgraded <code> js-yaml </code> version to 3.13.1, and <code> lodash </code> version to 4.17.15 (RS31819) </p> </li> <li> <p> Added an alert for actions that run for an extended period of time. For example, a notification is sent when an action like updating database property runs for more than a configurable threshold. Default value is set to 24 hours. </p> </li> </ul> <h2 id="information"> Information </h2> <ul> <li> End of Life (EOL) for Redis Enterprise Software 5.4, as well as for Redis Modules and previous RS versions, can be found <a href="https://docs.redis.com/latest/rs/installing-upgrading/product-lifecycle"> here </a> . </li> <li> Google Chrome browser on macOS Catalina requires self-signed certificate generated after June 2019 to include the extendedKeyUsage field in order to connect to the RS admin console. If you use a self-signed certificate that does not include this field, <a href="/docs/latest/operate/rs/security/certificates/updating-certificates/"> update the self-signed certificate </a> . </li> <li> When you upgrade an Active-Active Redis with active AOF from version RS 5.4.2 or lower to version RS 5.4.4 or higher: <ul> <li> If replication is enabled, you must run the BGREWRITEAOF command on all replica shards after the upgrade. </li> <li> If replication is not enabled, you must run the BGREWRITEAOF command on all shards after the upgrade. </li> </ul> </li> </ul> <h2 id="important-fixes"> Important fixes </h2> <ul> <li> RS23396 - Improved the disconnection mechanism in case of inactive UI session </li> <li> RS27924 - Added descriptive error messages in the UI console when validating the license </li> <li> RS29968 - Improved internal mechanism to better support high scale of clients connections </li> <li> RS35675 - Updated the upgrade process of Active-Active Redis databases to save causal consistency and encryption flags </li> <li> RS36922 - Fixed an issue in a specific cluster upgrade scenario from versions earlier than RS 5.4.0 to RS 5.4.0 or higher </li> </ul> <h2 id="known-limitations"> Known limitations </h2> <h3 id="upgrade"> Upgrade </h3> <ul> <li> When you upgrade a cluster from version 5.0.2-20 to version 5.4.14, you must first upgrade to version 5.2.2 and then to version 5.4.14. </li> <li> <a href="/docs/latest/operate/rs/release-notes/legacy-release-notes/rs-5-4-2-april-2019/"> RS 5.4.2 </a> introduced new Active-Active Redis (CRDB) capabilities that improve its compatibility with open source Redis. Now the string data-type in Active-Active Redis (CRDB) is implicitly and dynamically typed, just like open source Redis. To use the new capabilities on nodes that are upgraded from version RS 5.4.2 or lower, you must <a href="/docs/latest/operate/rs/installing-upgrading/upgrading/#upgrading-crdbs"> upgrade the CRDB protocol </a> . </li> <li> Before you upgrade a database with RediSearch Module to Redis 5.0, you must <a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/install/upgrade-module/"> upgrade the RediSearch Module </a> to version 1.4.2 or above. </li> <li> Node upgrade fails if the SSL certificates were configured in version 5.0.2 or above by manually updating the certificates on the disk instead of <a href="/docs/latest/operate/rs/security/certificates/updating-certificates/"> updating them through the API </a> . For assistance with this issue, <a href="https://redislabs.com/company/support/"> contact Redis support </a> . </li> <li> We recommend that you test module upgrade commands in a test environment before you upgrade modules in a production environment. The module upgrade arguments are not validated during the upgrade process and incorrect arguments can cause unexpected downtime. </li> <li> Starting from RS 5.4.2, to preserve the current Redis major.minor version during database upgrade you must use the <code> keep_redis_version </code> option instead of <code> keep_current_version </code> . </li> </ul> <h3 id="cluster-api"> Cluster API </h3> <ul> <li> <p> The API for removing a node is updated in RS 5.4.2 or higher. The API call must include json data and the "Content-Type: application/json" header. For example: </p> <p> <code> curl -X POST -H "Content-Type: application/json" -i -k -u [email protected]:password https://localhost:9443/v1/nodes/3/actions/remove --data "{}" </code> </p> </li> </ul> <h3 id="discovery-service"> Discovery service </h3> <ul> <li> For <a href="/docs/latest/operate/rs/databases/durability-ha/discovery-service/"> Redis Sentinel (Discovery Service) </a> , every database name must be unique across the cluster. </li> </ul> <h3 id="redis-commands"> Redis commands </h3> <ul> <li> The capability of disabling specific Redis commands does not work on commands specific to Redis Modules. </li> <li> The CLIENT ID command cannot guarantee incremental IDs between clients that connect to different nodes under multi proxy policies. </li> <li> CLIENT UNBLOCK command is not supported in RS 5.4 and above </li> <li> Starting from RS 5.4.2 and after upgrading the CRDB, TYPE command for string data-type in CRDBs return "string" (OSS Redis standard). </li> </ul> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/release-notes/legacy-release-notes/rs-5-4-14-february-2020/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/groupserver.html
<section class="prose w-full py-12"> <h1> Commands </h1> </section>
https://redis.io/docs/latest/operate/rs/references/rest-api/requests/bdbs/upgrade/.html
<section class="prose w-full py-12 max-w-none"> <h1> Database upgrade requests </h1> <p class="text-lg -mt-5 mb-10"> Database upgrade requests </p> <table> <thead> <tr> <th> Method </th> <th> Path </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="#post-bdbs-upgrade"> POST </a> </td> <td> <code> /v1/bdbs/{uid}/upgrade </code> </td> <td> Upgrade database </td> </tr> </tbody> </table> <h2 id="post-bdbs-upgrade"> Upgrade database </h2> <pre><code>POST /v1/bdbs/{int: uid}/upgrade </code></pre> <p> Upgrade a database. </p> <h4 id="required-permissions"> Required permissions </h4> <table> <thead> <tr> <th> Permission name </th> </tr> </thead> <tbody> <tr> <td> <a href="/docs/latest/operate/rs/references/rest-api/permissions/#update_bdb_with_action"> update_bdb_with_action </a> </td> </tr> </tbody> </table> <h3 id="post-request"> Request </h3> <h4 id="example-http-request"> Example HTTP request </h4> <pre><code>POST /bdbs/1/upgrade </code></pre> <h4 id="example-json-body"> Example JSON body </h4> <div class="highlight"> <pre class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"swap_roles"</span><span class="p">:</span> <span class="kc">true</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"may_discard_data"</span><span class="p">:</span> <span class="kc">false</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <h4 id="request-headers"> Request headers </h4> <table> <thead> <tr> <th> Key </th> <th> Value </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> Host </td> <td> cnm.cluster.fqdn </td> <td> Domain name </td> </tr> <tr> <td> Accept </td> <td> application/json </td> <td> Accepted media type </td> </tr> </tbody> </table> <h4 id="request-body"> Request body </h4> <table> <thead> <tr> <th> Field </th> <th> Type </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> force_restart </td> <td> boolean </td> <td> Restart shards even if no version change (default: false) </td> </tr> <tr> <td> keep_redis_version </td> <td> boolean </td> <td> Keep current Redis version (default: false). Deprecated as of Redis Enterprise Software v7.8.2. To upgrade modules without upgrading the Redis database version, set <code> redis_version </code> to the current Redis database version instead. </td> </tr> <tr> <td> keep_crdt_protocol_version </td> <td> boolean </td> <td> Keep current crdt protocol version (default: false) </td> </tr> <tr> <td> may_discard_data </td> <td> boolean </td> <td> Discard data in a non-replicated, non-persistent bdb (default: false) </td> </tr> <tr> <td> force_discard </td> <td> boolean </td> <td> Discard data even if the bdb is replicated and/or persistent (default: false) </td> </tr> <tr> <td> preserve_roles </td> <td> boolean </td> <td> Preserve shards' master/replica roles (requires an extra failover) (default: false) </td> </tr> <tr> <td> parallel_shards_upgrade </td> <td> integer </td> <td> Max number of shards to upgrade in parallel (default: all) </td> </tr> <tr> <td> modules </td> <td> list of modules </td> <td> List of dicts representing the modules that will be upgraded. As of Redis Enterprise Software v7.8.2, <code> current_module </code> and <code> new_module </code> are deprecated. <br/> <br/> Each dict includes: <br/> <br/> • <code> current_module </code> : uid of a module to upgrade (deprecated) <br/> <br/> • <code> new_module </code> : uid of the module we want to upgrade to (deprecated) <br/> <br/> • <code> new_module_args </code> : args list for the new module (no defaults for the three module-related parameters). </td> </tr> <tr> <td> redis_version </td> <td> version number </td> <td> Upgrades the database to the specified Redis version instead of the latest version. To upgrade modules without upgrading the Redis database version, set <code> redis_version </code> to the current Redis database version instead. </td> </tr> <tr> <td> latest_with_modules </td> <td> boolean </td> <td> Upgrades the database to the latest Redis version and latest supported versions of modules available in the cluster. (default: true as of v7.8.2) Deprecated as of Redis Enterprise Software v7.8.2. </td> </tr> </tbody> </table> <h3 id="post-response"> Response </h3> <p> Returns the upgraded <a href="/docs/latest/operate/rs/references/rest-api/objects/bdb/"> BDB object </a> . </p> <h4 id="example-json-body-1"> Example JSON body </h4> <div class="highlight"> <pre class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"uid"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"replication"</span><span class="p">:</span> <span class="kc">true</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"data_persistence"</span><span class="p">:</span> <span class="s2">"aof"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"// additional fields..."</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <h3 id="post-status-codes"> Status codes </h3> <table> <thead> <tr> <th> Code </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1"> 200 OK </a> </td> <td> Success, bdb upgrade initiated ( <code> action_uid </code> can be used to track progress) </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1"> 400 Bad Request </a> </td> <td> Malformed or bad command </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5"> 404 Not Found </a> </td> <td> bdb not found </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.7"> 406 Not Acceptable </a> </td> <td> New module version capabilities don't comply with the database configuration </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.1"> 500 Internal Server Error </a> </td> <td> Internal error </td> </tr> </tbody> </table> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/references/rest-api/requests/bdbs/upgrade/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/7.4/databases/active-active/manage/.html
<section class="prose w-full py-12 max-w-none"> <h1> Manage Active-Active databases </h1> <p class="text-lg -mt-5 mb-10"> Manage your Active-Active database settings. </p> <p> You can configure and manage your Active-Active database from either the Cluster Manager UI or the command line. </p> <p> To change the global configuration of the Active-Active database, use <a href="/docs/latest/operate/rs/7.4/references/cli-utilities/crdb-cli/"> <code> crdb-cli </code> </a> . </p> <p> If you need to apply changes locally to one database instance, you use the Cluster Manager UI or <a href="/docs/latest/operate/rs/7.4/references/cli-utilities/rladmin/"> <code> rladmin </code> </a> . </p> <h2 id="database-settings"> Database settings </h2> <p> Many Active-Active database settings can be changed after database creation. One notable exception is database clustering. Database clustering can't be turned on or off after the database has been created. </p> <h2 id="participating-clusters"> Participating clusters </h2> <p> You can add and remove participating clusters of an Active-Active database to change the topology. To manage the changes to Active-Active topology, use <a href="/docs/latest/operate/rs/7.4/references/cli-utilities/crdb-cli/"> <code> crdb-cli </code> </a> or the participating clusters list in the Cluster Manager UI. </p> <h3 id="add-participating-clusters"> Add participating clusters </h3> <p> All existing participating clusters must be online and in a syncing state when you add new participating clusters. </p> <p> New participating clusters create the Active-Active database instance based on the global Active-Active database configuration. After you add new participating clusters to an existing Active-Active database, the new database instance can accept connections and read operations. The new instance does not accept write operations until it is in the syncing state. </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> If an Active-Active database <a href="/docs/latest/operate/rs/7.4/databases/auto-tiering/"> runs on flash memory </a> , you cannot add participating clusters that run on RAM only. </div> </div> <p> To add a new participating cluster to an existing Active-Active configuration using the Cluster Manager UI: </p> <ol> <li> <p> Select the Active-Active database from the <strong> Databases </strong> list and go to its <strong> Configuration </strong> screen. </p> </li> <li> <p> Click <strong> Edit </strong> . </p> </li> <li> <p> In the <strong> Participating clusters </strong> section, go to <strong> Other participating clusters </strong> and click <strong> + Add cluster </strong> . </p> </li> <li> <p> In the <strong> Add cluster </strong> configuration panel, enter the new cluster's URL, port number, and the admin username and password for the new participating cluster: </p> <a href="/docs/latest/images/rs/screenshots/databases/active-active-databases/participating-clusters-add-cluster.png" sdata-lightbox="/images/rs/screenshots/databases/active-active-databases/participating-clusters-add-cluster.png"> <img alt="Add cluster panel." src="/docs/latest/images/rs/screenshots/databases/active-active-databases/participating-clusters-add-cluster.png"/> </a> </li> <li> <p> Click <strong> Join cluster </strong> to add the cluster to the list of participating clusters. </p> </li> <li> <p> Click <strong> Save </strong> . </p> </li> </ol> <h3 id="remove-participating-clusters"> Remove participating clusters </h3> <p> All existing participating clusters must be online and in a syncing state when you remove an online participating cluster. If you must remove offline participating clusters, you can forcefully remove them. If a forcefully removed participating cluster tries to rejoin the cluster, its Active-Active database membership will be out of date. The joined participating clusters reject updates sent from the removed participating cluster. To prevent rejoin attempts, purge the forcefully removed instance from the participating cluster. </p> <p> To remove a participating cluster using the Cluster Manager UI: </p> <ol> <li> <p> Select the Active-Active database from the <strong> Databases </strong> list and go to its <strong> Configuration </strong> screen. </p> </li> <li> <p> Click <strong> Edit </strong> . </p> </li> <li> <p> In the <strong> Participating clusters </strong> section, point to the cluster you want to delete in the <strong> Other participating clusters </strong> list: </p> <a href="/docs/latest/images/rs/screenshots/databases/active-active-databases/participating-clusters-edit-delete.png" sdata-lightbox="/images/rs/screenshots/databases/active-active-databases/participating-clusters-edit-delete.png"> <img alt="Edit and delete buttons appear when you point to an entry in the Other participating clusters list." src="/docs/latest/images/rs/screenshots/databases/active-active-databases/participating-clusters-edit-delete.png"/> </a> </li> <li> <p> Click <a href="/docs/latest/images/rs/buttons/delete-button.png#no-click" sdata-lightbox="/images/rs/buttons/delete-button.png#no-click"> <img alt="The Delete button" class="inline" src="/docs/latest/images/rs/buttons/delete-button.png#no-click" width="25px"/> </a> to remove the cluster. </p> </li> <li> <p> Click <strong> Save </strong> . </p> </li> </ol> <h2 id="replication-backlog"> Replication backlog </h2> <p> Redis databases that use <a href="/docs/latest/operate/rs/7.4/databases/durability-ha/replication/"> replication for high availability </a> maintain a replication backlog (per shard) to synchronize the primary and replica shards of a database. In addition to the database replication backlog, Active-Active databases maintain a backlog (per shard) to synchronize the database instances between clusters. </p> <p> By default, both the database and Active-Active replication backlogs are set to one percent (1%) of the database size divided by the number of shards. This can range between 1MB to 250MB per shard for each backlog. </p> <h3 id="change-the-replication-backlog-size"> Change the replication backlog size </h3> <p> Use the <a href="/docs/latest/operate/rs/7.4/references/cli-utilities/crdb-cli/"> <code> crdb-cli </code> </a> utility to control the size of the replication backlogs. You can set it to <code> auto </code> or set a specific size. </p> <p> Update the database replication backlog configuration with the <code> crdb-cli </code> command shown below. </p> <div class="highlight"> <pre class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">crdb-cli crdb update --crdb-guid &lt;crdb_guid&gt; --default-db-config "{\"repl_backlog_size\": &lt;size in MB | 'auto'&gt;}" </span></span></code></pre> </div> <p> Update the Active-Active (CRDT) replication backlog with the command shown below: </p> <div class="highlight"> <pre class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">crdb-cli crdb update --crdb-guid &lt;crdb_guid&gt; --default-db-config "{\"crdt_repl_backlog_size\": &lt;size in MB | 'auto'&gt;}" </span></span></code></pre> </div> <h2 id="data-persistence"> Data persistence </h2> <p> Active-Active supports AOF (Append-Only File) data persistence only. Snapshot persistence is <em> not </em> supported for Active-Active databases and should not be used. </p> <p> If an Active-Active database is currently using snapshot data persistence, use <code> crdb-cli </code> to switch to AOF persistence: </p> <div class="highlight"> <pre class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl"> crdb-cli crdb update --crdb-guid &lt;CRDB_GUID&gt; --default-db-config '{"data_persistence": "aof", "aof_policy":"appendfsync-every-sec"}' </span></span></code></pre> </div> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/databases/active-active/manage/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/dbsize/.html
<section class="prose w-full py-12"> <h1 class="command-name"> DBSIZE </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">DBSIZE</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available since: </dt> <dd class="m-0"> 1.0.0 </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(1) </dd> <dt class="font-semibold text-redis-ink-900 m-0"> ACL categories: </dt> <dd class="m-0"> <code> @keyspace </code> <span class="mr-1 last:hidden"> , </span> <code> @read </code> <span class="mr-1 last:hidden"> , </span> <code> @fast </code> <span class="mr-1 last:hidden"> , </span> </dd> </dl> <p> Return the number of keys in the currently-selected database. </p> <h2 id="resp2resp3-reply"> RESP2/RESP3 Reply </h2> <a href="../../develop/reference/protocol-spec#integers"> Integer reply </a> : the number of keys in the currently-selected database. <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/dbsize/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/references/rest-api/objects/statistics/shard-metrics/.html
<section class="prose w-full py-12 max-w-none"> <h1> Shard metrics </h1> <p class="text-lg -mt-5 mb-10"> Documents the shard metrics used with Redis Enterprise Software REST API calls. </p> <table> <thead> <tr> <th> Metric name </th> <th> Type </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> aof_rewrite_inprog </td> <td> float </td> <td> The number of simultaneous AOF rewrites that are in progress </td> </tr> <tr> <td> avg_ttl </td> <td> float </td> <td> Estimated average time to live of a random key (msec) </td> </tr> <tr> <td> big_del_flash </td> <td> float </td> <td> Rate of key deletes for keys on flash (BigRedis) (key access/sec). Only returned when BigRedis is enabled. </td> </tr> <tr> <td> big_del_ram </td> <td> float </td> <td> Rate of key deletes for keys in RAM (BigRedis) (key access/sec); this includes write misses (new keys created). Only returned when BigRedis is enabled. </td> </tr> <tr> <td> big_fetch_flash </td> <td> float </td> <td> Rate of key reads/updates for keys on flash (BigRedis) (key access/sec). Only returned when BigRedis is enabled. </td> </tr> <tr> <td> big_fetch_ram </td> <td> float </td> <td> Rate of key reads/updates for keys in RAM (BigRedis) (key access/sec). Only returned when BigRedis is enabled. </td> </tr> <tr> <td> big_io_ratio_flash </td> <td> float </td> <td> Rate of key operations on flash. Can be used to compute the ratio of I/O operations (key access/sec). Only returned when BigRedis is enabled. </td> </tr> <tr> <td> big_io_ratio_redis </td> <td> float </td> <td> Rate of Redis operations on keys. Can be used to compute the ratio of I/O operations) (key access/sec). Only returned when BigRedis is enabled. </td> </tr> <tr> <td> big_write_flash </td> <td> float </td> <td> Rate of key writes for keys on flash (BigRedis) (key access/sec). Only returned when BigRedis is enabled. </td> </tr> <tr> <td> big_write_ram </td> <td> float </td> <td> Rate of key writes for keys in RAM (BigRedis) (key access/sec); this includes write misses (new keys created). Only returned when BigRedis is enabled. </td> </tr> <tr> <td> bigstore_io_dels </td> <td> float </td> <td> Rate of key deletions from flash (key access/sec). Only returned when BigRedis is enabled. </td> </tr> <tr> <td> bigstore_io_read_bytes </td> <td> float </td> <td> Throughput of I/O read operations against backend flash for all shards of the DB (BigRedis) (bytes/sec). Only returned when BigRedis is enabled. </td> </tr> <tr> <td> bigstore_io_reads </td> <td> float </td> <td> Rate of key reads from flash (key access/sec). Only returned when BigRedis is enabled. </td> </tr> <tr> <td> bigstore_io_write_bytes </td> <td> float </td> <td> Throughput of I/O write operations against backend flash for all shards of the DB (BigRedis) (bytes/sec). Only returned when BigRedis is enabled. </td> </tr> <tr> <td> bigstore_io_writes </td> <td> float </td> <td> Rate of key writes from flash (key access/sec). Only returned when BigRedis is enabled. </td> </tr> <tr> <td> bigstore_iops </td> <td> float </td> <td> Rate of I/O operations against backend flash for all shards of the DB (BigRedis) (ops/sec). Only returned when BigRedis is enabled. </td> </tr> <tr> <td> bigstore_kv_ops </td> <td> float </td> <td> Rate of value read/write/del operations against backend flash for all shards of the DB (BigRedis) (key access/sec). Only returned when BigRedis is enabled. </td> </tr> <tr> <td> bigstore_objs_flash </td> <td> float </td> <td> Key count on flash (BigRedis). Only returned when BigRedis is enabled. </td> </tr> <tr> <td> bigstore_objs_ram </td> <td> float </td> <td> Key count in RAM (BigRedis). Only returned when BigRedis is enabled. </td> </tr> <tr> <td> bigstore_throughput </td> <td> float </td> <td> Throughput of I/O operations against backend flash for all shards of the DB (BigRedis) (bytes/sec). Only returned when BigRedis is enabled. </td> </tr> <tr> <td> blocked_clients </td> <td> float </td> <td> Count the clients waiting on a blocking call </td> </tr> <tr> <td> connected_clients </td> <td> float </td> <td> Number of client connections to the specific shard </td> </tr> <tr> <td> disk_frag_ratio </td> <td> float </td> <td> Flash fragmentation ratio (used/required). Only returned when BigRedis is enabled. </td> </tr> <tr> <td> evicted_objects </td> <td> float </td> <td> Rate of key evictions from DB (evictions/sec) </td> </tr> <tr> <td> expired_objects </td> <td> float </td> <td> Rate keys expired in DB (expirations/sec) </td> </tr> <tr> <td> fork_cpu_system </td> <td> float </td> <td> % cores utilization in system mode for the Redis shard fork child process </td> </tr> <tr> <td> fork_cpu_user </td> <td> float </td> <td> % cores utilization in user mode for the Redis shard fork child process </td> </tr> <tr> <td> last_save_time </td> <td> float </td> <td> Time of the last RDB save </td> </tr> <tr> <td> main_thread_cpu_system </td> <td> float </td> <td> % cores utilization in system mode for the Redis shard main thread </td> </tr> <tr> <td> main_thread_cpu_user </td> <td> float </td> <td> % cores utilization in user mode for the Redis shard main thread </td> </tr> <tr> <td> mem_frag_ratio </td> <td> float </td> <td> RAM fragmentation ratio (RSS/allocated RAM) </td> </tr> <tr> <td> mem_not_counted_for_evict </td> <td> float </td> <td> Portion of used_memory (in bytes) not counted for eviction and OOM errors </td> </tr> <tr> <td> mem_size_lua </td> <td> float </td> <td> Redis Lua scripting heap size (bytes) </td> </tr> <tr> <td> no_of_expires </td> <td> float </td> <td> Number of volatile keys on the shard </td> </tr> <tr> <td> no_of_keys </td> <td> float </td> <td> Number of keys in DB </td> </tr> <tr> <td> pubsub_channels </td> <td> float </td> <td> Count the pub/sub channels with subscribed clients </td> </tr> <tr> <td> pubsub_patterns </td> <td> float </td> <td> Count the pub/sub patterns with subscribed clients </td> </tr> <tr> <td> rdb_changes_since_last_save </td> <td> float </td> <td> Count changes since last RDB save </td> </tr> <tr> <td> read_hits </td> <td> float </td> <td> Rate of read operations accessing an existing key (ops/sec) </td> </tr> <tr> <td> read_misses </td> <td> float </td> <td> Rate of read operations accessing a nonexistent key (ops/sec) </td> </tr> <tr> <td> shard_cpu_system </td> <td> float </td> <td> % cores utilization in system mode for the Redis shard process </td> </tr> <tr> <td> shard_cpu_user </td> <td> float </td> <td> % cores utilization in user mode for the Redis shard process </td> </tr> <tr> <td> total_req </td> <td> float </td> <td> Rate of operations on DB (ops/sec) </td> </tr> <tr> <td> used_memory </td> <td> float </td> <td> Memory used by shard (in BigRedis this includes flash) (bytes) </td> </tr> <tr> <td> used_memory_peak </td> <td> float </td> <td> The largest amount of memory used by this shard (bytes) </td> </tr> <tr> <td> used_memory_rss </td> <td> float </td> <td> Resident set size of this shard (bytes) </td> </tr> <tr> <td> write_hits </td> <td> float </td> <td> Rate of write operations accessing an existing key (ops/sec) </td> </tr> <tr> <td> write_misses </td> <td> float </td> <td> Rate of write operations accessing a nonexistent key (ops/sec) </td> </tr> </tbody> </table> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/references/rest-api/objects/statistics/shard-metrics/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/client-info/.html
<section class="prose w-full py-12"> <h1 class="command-name"> CLIENT INFO </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">CLIENT INFO</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available since: </dt> <dd class="m-0"> 6.2.0 </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(1) </dd> <dt class="font-semibold text-redis-ink-900 m-0"> ACL categories: </dt> <dd class="m-0"> <code> @slow </code> <span class="mr-1 last:hidden"> , </span> <code> @connection </code> <span class="mr-1 last:hidden"> , </span> </dd> </dl> <p> The command returns information and statistics about the current client connection in a mostly human readable format. </p> <p> The reply format is identical to that of <a href="/docs/latest/commands/client-list/"> <code> CLIENT LIST </code> </a> , and the content consists only of information about the current client. </p> <h2 id="examples"> Examples </h2> <div class="bg-slate-900 border-b border-slate-700 rounded-t-xl px-4 py-3 w-full flex"> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M2.5 10C2.5 5.85786 5.85786 2.5 10 2.5C14.1421 2.5 17.5 5.85786 17.5 10C17.5 14.1421 14.1421 17.5 10 17.5C5.85786 17.5 2.5 14.1421 2.5 10Z"> </path> </svg> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M10 2.5L18.6603 17.5L1.33975 17.5L10 2.5Z"> </path> </svg> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M10 2.5L12.0776 7.9322L17.886 8.22949L13.3617 11.8841L14.8738 17.5L10 14.3264L5.1262 17.5L6.63834 11.8841L2.11403 8.22949L7.92238 7.9322L10 2.5Z"> </path> </svg> </div> <form class="redis-cli overflow-y-auto max-h-80"> <pre tabindex="0">redis&gt; CLIENT INFO "id=820347 addr=127.0.0.1:38226 laddr=127.0.0.1:6379 fd=13 name= age=15074 idle=0 flags=N db=0 sub=0 psub=0 ssub=0 multi=-1 watch=0 qbuf=26 qbuf-free=20448 argv-mem=10 multi-mem=0 rbs=1024 rbp=0 obl=0 oll=0 omem=0 tot-mem=22426 events=r cmd=client|info user=interwebz redir=-1 resp=2 lib-name= lib-ver= " </pre> <div class="prompt" style=""> <span> redis&gt; </span> <input autocomplete="off" name="prompt" spellcheck="false" type="text"/> </div> </form> <h2 id="resp2resp3-reply"> RESP2/RESP3 Reply </h2> <a href="../../develop/reference/protocol-spec#bulk-strings"> Bulk string reply </a> : a unique string for the current client, as described at the <code> CLIENT LIST </code> page. <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/client-info/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/xgroup-setid/.html
<section class="prose w-full py-12"> <h1 class="command-name"> XGROUP SETID </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">XGROUP SETID key group &lt;id | $&gt; [ENTRIESREAD entries-read]</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available since: </dt> <dd class="m-0"> 5.0.0 </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(1) </dd> <dt class="font-semibold text-redis-ink-900 m-0"> ACL categories: </dt> <dd class="m-0"> <code> @write </code> <span class="mr-1 last:hidden"> , </span> <code> @stream </code> <span class="mr-1 last:hidden"> , </span> <code> @slow </code> <span class="mr-1 last:hidden"> , </span> </dd> </dl> <p> Set the <strong> last delivered ID </strong> for a consumer group. </p> <p> Normally, a consumer group's last delivered ID is set when the group is created with <a href="/docs/latest/commands/xgroup-create/"> <code> XGROUP CREATE </code> </a> . The <code> XGROUP SETID </code> command allows modifying the group's last delivered ID, without having to delete and recreate the group. For instance if you want the consumers in a consumer group to re-process all the messages in a stream, you may want to set its next ID to 0: </p> <pre><code>XGROUP SETID mystream mygroup 0 </code></pre> <p> The optional <code> entries_read </code> argument can be specified to enable consumer group lag tracking for an arbitrary ID. An arbitrary ID is any ID that isn't the ID of the stream's first entry, its last entry or the zero ("0-0") ID. This can be useful you know exactly how many entries are between the arbitrary ID (excluding it) and the stream's last entry. In such cases, the <code> entries_read </code> can be set to the stream's <code> entries_added </code> subtracted with the number of entries. </p> <h2 id="resp2resp3-reply"> RESP2/RESP3 Reply </h2> <a href="../../develop/reference/protocol-spec#simple-strings"> Simple string reply </a> : <code> OK </code> . <br/> <h2> History </h2> <ul> <li> Starting with Redis version 7.0.0: Added the optional <code> entries_read </code> argument. </li> </ul> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/xgroup-setid/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/ts.add/.html
<section class="prose w-full py-12"> <h1 class="command-name"> TS.ADD </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">TS.ADD key timestamp value [RETENTION retentionPeriod] [ENCODING &lt;COMPRESSED|UNCOMPRESSED&gt;] [CHUNK_SIZE size] [DUPLICATE_POLICY policy] [ON_DUPLICATE policy_ovr] [IGNORE ignoreMaxTimediff ignoreMaxValDiff] [LABELS [label value ...]] </pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available in: </dt> <dd class="m-0"> <a href="/docs/stack"> Redis Stack </a> / <a href="/docs/data-types/timeseries"> TimeSeries 1.0.0 </a> </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(M) when M is the amount of compaction rules or O(1) with no compaction </dd> </dl> <p> Append a sample to a time series </p> <p> <a href="#examples"> Examples </a> </p> <h2 id="required-arguments"> Required arguments </h2> <details open=""> <summary> <code> key </code> </summary> <p> is key name for the time series. </p> </details> <details open=""> <summary> <code> timestamp </code> </summary> <p> is Unix time (integer, in milliseconds) specifying the sample timestamp or <code> * </code> to set the sample timestamp to the Unix time of the server's clock. </p> <p> Unix time is the number of milliseconds that have elapsed since 00:00:00 UTC on 1 January 1970, the Unix epoch, without adjustments made due to leap seconds. </p> </details> <details open=""> <summary> <code> value </code> </summary> <p> is (double) numeric data value of the sample. The double number should follow <a href="https://tools.ietf.org/html/rfc7159"> RFC 7159 </a> (JSON standard). In particular, the parser rejects overly large values that do not fit in binary64. It does not accept NaN or infinite values. </p> </details> <p> <note> <b> Notes: </b> </note> </p> <ul> <li> <p> When specified key does not exist, a new time series is created. </p> <p> if a <a href="/docs/latest/develop/data-types/timeseries/configuration#compaction_policy"> COMPACTION_POLICY </a> configuration parameter is defined, compacted time series would be created as well. </p> </li> <li> <p> If <code> timestamp </code> is older than the retention period compared to the maximum existing timestamp, the sample is discarded and an error is returned. </p> </li> <li> <p> When adding a sample to a time series for which compaction rules are defined: </p> <ul> <li> If all the original samples for an affected aggregated time bucket are available, the compacted value is recalculated based on the reported sample and the original samples. </li> <li> If only a part of the original samples for an affected aggregated time bucket is available due to trimming caused in accordance with the time series RETENTION policy, the compacted value is recalculated based on the reported sample and the available original samples. </li> <li> If the original samples for an affected aggregated time bucket are not available due to trimming caused in accordance with the time series RETENTION policy, the compacted value bucket is not updated. </li> </ul> </li> <li> <p> Explicitly adding samples to a compacted time series (using <code> TS.ADD </code> , <a href="/docs/latest/commands/ts.madd/"> <code> TS.MADD </code> </a> , <a href="/docs/latest/commands/ts.incrby/"> <code> TS.INCRBY </code> </a> , or <a href="/docs/latest/commands/ts.decrby/"> <code> TS.DECRBY </code> </a> ) may result in inconsistencies between the raw and the compacted data. The compaction process may override such samples. </p> </li> </ul> <h2 id="optional-arguments"> Optional arguments </h2> <p> The following arguments are optional because they can be set by <a href="/docs/latest/commands/ts.create/"> <code> TS.CREATE </code> </a> . </p> <details open=""> <summary> <code> RETENTION retentionPeriod </code> </summary> <p> is maximum retention period, compared to the maximum existing timestamp, in milliseconds. </p> <p> Use it only if you are creating a new time series. It is ignored if you are adding samples to an existing time series. See <code> RETENTION </code> in <a href="/docs/latest/commands/ts.create/"> <code> TS.CREATE </code> </a> . </p> </details> <details open=""> <summary> <code> ENCODING enc </code> </summary> <p> specifies the series sample encoding format. </p> <p> Use it only if you are creating a new time series. It is ignored if you are adding samples to an existing time series. See <code> ENCODING </code> in <a href="/docs/latest/commands/ts.create/"> <code> TS.CREATE </code> </a> . </p> </details> <details open=""> <summary> <code> CHUNK_SIZE size </code> </summary> <p> is memory size, in bytes, allocated for each data chunk. </p> <p> Use it only if you are creating a new time series. It is ignored if you are adding samples to an existing time series. See <code> CHUNK_SIZE </code> in <a href="/docs/latest/commands/ts.create/"> <code> TS.CREATE </code> </a> . </p> </details> <details open=""> <summary> <code> DUPLICATE_POLICY policy </code> </summary> <p> is policy for handling insertion ( <a href="/docs/latest/commands/ts.add/"> <code> TS.ADD </code> </a> and <a href="/docs/latest/commands/ts.madd/"> <code> TS.MADD </code> </a> ) of multiple samples with identical timestamps. </p> <p> Use it only if you are creating a new time series. It is ignored if you are adding samples to an existing time series. See <code> DUPLICATE_POLICY </code> in <a href="/docs/latest/commands/ts.create/"> <code> TS.CREATE </code> </a> . </p> </details> <details open=""> <summary> <code> ON_DUPLICATE policy_ovr </code> </summary> <p> is overwrite key and database configuration for <a href="/docs/latest/develop/data-types/timeseries/configuration#duplicate_policy"> DUPLICATE_POLICY </a> , the policy for handling samples with identical timestamps. This override is effective only for this single command and does not set the time series duplication policy (which can be set with <a href="/docs/latest/commands/ts.alter/"> <code> TS.ALTER </code> </a> ). </p> <p> <code> policy_ovr </code> can be one of the following values: </p> <ul> <li> <code> BLOCK </code> : ignore any newly reported value and reply with an error </li> <li> <code> FIRST </code> : ignore any newly reported value </li> <li> <code> LAST </code> : override with the newly reported value </li> <li> <code> MIN </code> : only override if the value is lower than the existing value </li> <li> <code> MAX </code> : only override if the value is higher than the existing value </li> <li> <code> SUM </code> : If a previous sample exists, add the new sample to it so that the updated value is set to (previous + new). If no previous sample exists, the value is set to the new value. </li> </ul> <p> This argument has no effect when a new time series is created by this command. </p> </details> <details open=""> <summary> <code> IGNORE ignoreMaxTimediff ignoreMaxValDiff </code> </summary> <p> is the policy for handling duplicate samples. A new sample is considered a duplicate and is ignored if the following conditions are met: </p> <ul> <li> The time series is not a compaction; </li> <li> The time series' <code> DUPLICATE_POLICY </code> IS <code> LAST </code> ; </li> <li> The sample is added in-order ( <code> timestamp ≥ max_timestamp </code> ); </li> <li> The difference of the current timestamp from the previous timestamp ( <code> timestamp - max_timestamp </code> ) is less than or equal to <code> IGNORE_MAX_TIME_DIFF </code> ; </li> <li> The absolute value difference of the current value from the value at the previous maximum timestamp ( <code> abs(value - value_at_max_timestamp </code> ) is less than or equal to <code> IGNORE_MAX_VAL_DIFF </code> . </li> </ul> <p> where <code> max_timestamp </code> is the timestamp of the sample with the largest timestamp in the time series, and <code> value_at_max_timestamp </code> is the value at <code> max_timestamp </code> . </p> <p> When not specified: set to the global <a href="/docs/latest/develop/data-types/timeseries/configuration#ignore_max_time_diff-and-ignore_max_val_diff"> IGNORE_MAX_TIME_DIFF </a> and <a href="/docs/latest/develop/data-types/timeseries/configuration#ignore_max_time_diff-and-ignore_max_val_diff"> IGNORE_MAX_VAL_DIFF </a> , which are, by default, both set to 0. </p> <p> These parameters are used when creating a new time series to set the per-key parameters, and are ignored when called with an existing time series (the existing per-key configuration parameters is used). </p> </details> <details open=""> <summary> <code> LABELS {label value}... </code> </summary> <p> is set of label-value pairs that represent metadata labels of the time series. </p> <p> Use it only if you are creating a new time series. It is ignored if you are adding samples to an existing time series. See <code> LABELS </code> in <a href="/docs/latest/commands/ts.create/"> <code> TS.CREATE </code> </a> . </p> </details> <p> <note> <b> Notes: </b> </note> </p> <ul> <li> You can use this command to create a new time series and add data to it in a single command. <code> RETENTION </code> , <code> ENCODING </code> , <code> CHUNK_SIZE </code> , <code> DUPLICATE_POLICY </code> , <code> IGNORE </code> , and <code> LABELS </code> are used only when creating a new time series, and ignored when adding samples to an existing time series. </li> <li> Setting <code> RETENTION </code> and <code> LABELS </code> introduces additional time complexity. </li> </ul> <h2 id="return-value"> Return value </h2> <p> Returns one of these replies: </p> <ul> <li> <a href="/docs/latest/develop/reference/protocol-spec/#integers"> Integer reply </a> - the timestamp of the upserted sample. If the sample is ignored (See <code> IGNORE </code> in <a href="/docs/latest/commands/ts.create/"> <code> TS.CREATE </code> </a> ), the reply will be the largest timestamp in the time series. </li> <li> [] on error (invalid arguments, wrong key type, etc.), when duplication policy is <code> BLOCK </code> , or when <code> timestamp </code> is older than the retention period compared to the maximum existing timestamp </li> </ul> <h2 id="complexity"> Complexity </h2> <p> If a compaction rule exists on a time series, the performance of <code> TS.ADD </code> can be reduced. The complexity of <code> TS.ADD </code> is always <code> O(M) </code> , where <code> M </code> is the number of compaction rules or <code> O(1) </code> with no compaction. </p> <h2 id="examples"> Examples </h2> <details open=""> <summary> <b> Append a sample to a temperature time series </b> </summary> <p> Create a temperature time series, set its retention to 1 year, and append a sample. </p> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">127.0.0.1:6379&gt; TS.ADD temperature:3:11 <span class="m">1548149183000</span> <span class="m">27</span> RETENTION <span class="m">31536000000</span> </span></span><span class="line"><span class="cl"><span class="o">(</span>integer<span class="o">)</span> <span class="m">1548149183000</span></span></span></code></pre> </div> <p> <note> <b> Note: </b> If a time series with such a name already exists, the sample is added, but the retention does not change. </note> </p> <p> Add a sample to the time series, setting the sample's timestamp to the current Unix time of the server's clock. </p> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">127.0.0.1:6379&gt; TS.ADD temperature:3:11 * <span class="m">30</span> </span></span><span class="line"><span class="cl"><span class="o">(</span>integer<span class="o">)</span> <span class="m">1662042954573</span></span></span></code></pre> </div> </details> <h2 id="see-also"> See also </h2> <p> <a href="/docs/latest/commands/ts.create/"> <code> TS.CREATE </code> </a> </p> <h2 id="related-topics"> Related topics </h2> <p> <a href="/docs/latest/develop/data-types/timeseries/"> RedisTimeSeries </a> </p> <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/ts.add/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/json.toggle/.html
<section class="prose w-full py-12"> <h1 class="command-name"> JSON.TOGGLE </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">JSON.TOGGLE key path</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available in: </dt> <dd class="m-0"> <a href="/docs/stack"> Redis Stack </a> / <a href="/docs/data-types/json"> JSON 2.0.0 </a> </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(1) when path is evaluated to a single value, O(N) when path is evaluated to multiple values, where N is the size of the key </dd> </dl> <p> Toggle a Boolean value stored at <code> path </code> </p> <p> <a href="#examples"> Examples </a> </p> <h2 id="required-arguments"> Required arguments </h2> <details open=""> <summary> <code> key </code> </summary> <p> is key to modify. </p> </details> <h2 id="optional-arguments"> Optional arguments </h2> <details open=""> <summary> <code> path </code> </summary> <p> is JSONPath to specify. Default is root <code> $ </code> . </p> </details> <h2 id="return"> Return </h2> <p> JSON.TOGGLE returns an array of integer replies for each path, the new value ( <code> 0 </code> if <code> false </code> or <code> 1 </code> if <code> true </code> ), or <code> nil </code> for JSON values matching the path that are not Boolean. For more information about replies, see <a href="/docs/latest/develop/reference/protocol-spec/"> Redis serialization protocol specification </a> . </p> <h2 id="examples"> Examples </h2> <details open=""> <summary> <b> Toogle a Boolean value stored at <code> path </code> </b> </summary> <p> Create a JSON document. </p> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis&gt; JSON.SET doc $ <span class="s1">'{"bool": true}'</span> </span></span><span class="line"><span class="cl">OK</span></span></code></pre> </div> <p> Toggle the Boolean value. </p> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis&gt; JSON.TOGGLE doc $.bool </span></span><span class="line"><span class="cl">1<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">0</span></span></span></code></pre> </div> <p> Get the updated document. </p> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis&gt; JSON.GET doc $ </span></span><span class="line"><span class="cl"><span class="s2">"[{\"bool\":false}]"</span></span></span></code></pre> </div> <p> Toggle the Boolean value. </p> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis&gt; JSON.TOGGLE doc $.bool </span></span><span class="line"><span class="cl">1<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1</span></span></span></code></pre> </div> <p> Get the updated document. </p> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis&gt; JSON.GET doc $ </span></span><span class="line"><span class="cl"><span class="s2">"[{\"bool\":true}]"</span></span></span></code></pre> </div> </details> <h2 id="see-also"> See also </h2> <p> <a href="/docs/latest/commands/json.set/"> <code> JSON.SET </code> </a> | <a href="/docs/latest/commands/json.get/"> <code> JSON.GET </code> </a> </p> <h2 id="related-topics"> Related topics </h2> <ul> <li> <a href="/docs/latest/develop/data-types/json/"> RedisJSON </a> </li> <li> <a href="/docs/latest/develop/interact/search-and-query/indexing/"> Index and search JSON documents </a> </li> </ul> <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/json.toggle/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/clusters/configure/cluster-settings/.html
<section class="prose w-full py-12 max-w-none"> <h1> Cluster settings </h1> <p class="text-lg -mt-5 mb-10"> You can view and set various cluster settings such as cluster name, email service, time zone, and license. </p> <p> You can view and set various cluster settings, such as cluster name, email service, time zone, and license, on the <strong> Cluster &gt; Configuration </strong> page. </p> <h2 id="general-configuration-tab"> General configuration tab </h2> <h3 id="upload-cluster-license-key"> Upload cluster license key </h3> <p> After purchasing a cluster license and if your account has the "Admin" role, you can upload the cluster license key, either during initial cluster creation or at any time afterward. The license key defines various cluster settings, such as the maximum number of shards you can have in the cluster. For more detailed information see <a href="/docs/latest/operate/rs/clusters/configure/license-keys/"> Cluster license keys </a> . </p> <h3 id="view-max-number-of-allowed-shards"> View max number of allowed shards </h3> <p> The maximum number of allowed shards, which is determined by the cluster license key, appears in the <strong> Max number of shards </strong> field in the <strong> License </strong> section. </p> <h3 id="view-cluster-name"> View cluster name </h3> <p> The cluster name appears in the <strong> Cluster name </strong> field in the <strong> License </strong> section. This gives a common name that your team or Redis support can refer to. It is especially helpful if you have multiple clusters. </p> <h3 id="set-time-zone"> Set time zone </h3> <p> You can change the <strong> Time zone </strong> field to ensure the date, time fields, and log entries in the Cluster Manager UI are shown in your preferred time zone. This setting doesn't affect other system logs or services. </p> <h2 id="alert-settings-tab"> Alert settings tab </h2> <p> The <strong> Alert Settings </strong> tab lets you configure alerts that are relevant to the entire cluster, such as alerts for cluster utilization, nodes, node utilization, security, and database utilization. </p> <p> You can also configure email server settings and <a href="/docs/latest/operate/rs/clusters/monitoring/#send-alerts-by-email"> send alerts by email </a> to relevant users. </p> <h3 id="configure-email-server-settings"> Configure email server settings </h3> <p> To enable email alerts: </p> <ol> <li> <p> Enter your email server details in the <strong> Email server settings </strong> section. </p> </li> <li> <p> Select a connection security method: </p> <ul> <li> <p> TLS/SSL </p> </li> <li> <p> STARTTLS </p> </li> <li> <p> None </p> </li> </ul> </li> <li> <p> Send a test email to verify your email server settings. </p> </li> </ol> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/clusters/configure/cluster-settings/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/kubernetes/release-notes/k8s-6-2-8-15-2022-01/.html
<section class="prose w-full py-12 max-w-none"> <h1> Redis Enterprise for Kubernetes Release Notes 6.2.8-15 (January 2022) </h1> <p class="text-lg -mt-5 mb-10"> Maintenance release with bug fixes </p> <h2 id="overview"> Overview </h2> <p> The Redis Enterprise K8s 6.2.8-15 is a maintenance release for the <a href="/docs/latest/operate/rs/release-notes/rs-6-2-8-october-2021/"> Redis Enterprise Software release 6.2.8 </a> and includes bug fixes. </p> <p> The key new features, bug fixes, and known limitations are described below. </p> <h2 id="images"> Images </h2> <p> This release includes the following container images: </p> <ul> <li> <strong> Redis Enterprise </strong> : <code> redislabs/redis:6.2.8-64 </code> or <code> redislabs/redis:6.2.8-64.rhel7-openshift </code> </li> <li> <strong> Operator </strong> : <code> redislabs/operator:6.2.8-15 </code> </li> <li> <strong> Services Rigger </strong> : <code> redislabs/k8s-controller:6.2.8-15 </code> or <code> redislabs/services-manager:6.2.8-15 </code> (on the Red Hat registry) </li> </ul> <h2 id="fixed-bugs"> Fixed bugs </h2> <ul> <li> <p> Upgrading with the bundle using <code> kubectl apply -f </code> fails giving error (RED-69570): </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">The CustomResourceDefinition <span class="s2">"redisenterpriseclusters.app.redislabs.com"</span> is invalid: spec.preserveUnknownFields: Invalid value: true: must be <span class="nb">false</span> in order to use defaults in the schema. </span></span></code></pre> </div> </li> <li> <p> Removed unneeded certificates from the Redis Enterprise Software container (RED-69661, RED-60086) </p> </li> </ul> <h2 id="known-limitations"> Known limitations </h2> <h3 id="large-clusters"> Large clusters </h3> <p> On clusters with more than 9 REC nodes, a Kubernetes upgrade can render the Redis cluster unresponsive in some cases. A fix is available in the 6.4.2-5 release. Upgrade your operator version to 6.4.2-5 or later before upgrading your Kubernetes cluster. (RED-93025) </p> <h3 id="long-cluster-names-cause-routes-to-be-rejected--red-25871"> Long cluster names cause routes to be rejected (RED-25871) </h3> <p> A cluster name longer than 20 characters will result in a rejected route configuration because the host part of the domain name will exceed 63 characters. The workaround is to limit cluster name to 20 characters or less. </p> <h3 id="cluster-cr-rec-errors-are-not-reported-after-invalid-updates-red-25542"> Cluster CR (REC) errors are not reported after invalid updates (RED-25542) </h3> <p> A cluster CR specification error is not reported if two or more invalid CR resources are updated in sequence. </p> <h3 id="an-unreachable-cluster-has-status-running-red-32805"> An unreachable cluster has status running (RED-32805) </h3> <p> When a cluster is in an unreachable state, the state is still <code> running </code> instead of being reported as an error. </p> <h3 id="readiness-probe-incorrect-on-failures-red-39300"> Readiness probe incorrect on failures (RED-39300) </h3> <p> STS Readiness probe does not mark a node as "not ready" when running <code> rladmin status </code> on node failure. </p> <h3 id="role-missing-on-replica-sets-red-39002"> Role missing on replica sets (RED-39002) </h3> <p> The <code> redis-enterprise-operator </code> role is missing permission on replica sets. </p> <h3 id="private-registries-are-not-supported-on-openshift-311-red-38579"> Private registries are not supported on OpenShift 3.11 (RED-38579) </h3> <p> OpenShift 3.11 does not support DockerHub private registries. This is a known OpenShift issue. </p> <h3 id="internal-dns-and-kubernetes-dns-may-have-conflicts-red-37462"> Internal DNS and Kubernetes DNS may have conflicts (RED-37462) </h3> <p> DNS conflicts are possible between the cluster <code> mdns_server </code> and the K8s DNS. This only impacts DNS resolution from within cluster nodes for Kubernetes DNS names. </p> <h3 id="5410-negatively-impacts-546-red-37233"> 5.4.10 negatively impacts 5.4.6 (RED-37233) </h3> <p> Kubernetes-based 5.4.10 deployments seem to negatively impact existing 5.4.6 deployments that share a Kubernetes cluster. </p> <h3 id="node-cpu-usage-is-reported-instead-of-pod-cpu-usage-red-36884"> Node CPU usage is reported instead of pod CPU usage (RED-36884) </h3> <p> In Kubernetes, the node CPU usage we report on is the usage of the Kubernetes worker node hosting the REC pod. </p> <h3 id="clusters-must-be-named-rec-in-olm-based-deployments-red-39825"> Clusters must be named "rec" in OLM-based deployments (RED-39825) </h3> <p> In OLM-deployed operators, the deployment of the cluster will fail if the name is not "rec". When the operator is deployed via the OLM, the security context constraints (scc) are bound to a specific service account name (i.e., "rec"). The workaround is to name the cluster "rec". </p> <h3 id="rec-clusters-fail-to-start-on-kubernetes-clusters-with-unsynchronized-clocks-red-47254"> REC clusters fail to start on Kubernetes clusters with unsynchronized clocks (RED-47254) </h3> <p> When REC clusters are deployed on Kubernetes clusters with unsynchronized clocks, the REC cluster does not start correctly. The fix is to use NTP to synchronize the underlying K8s nodes. </p> <h3 id="deleting-an-openshift-project-with-an-rec-deployed-may-hang-red-47192"> Deleting an OpenShift project with an REC deployed may hang (RED-47192) </h3> <p> When a REC cluster is deployed in a project (namespace) and has REDB resources, the REDB resources must be deleted first before the REC can be deleted. As such, until the REDB resources are deleted, the project deletion will hang. The fix is to delete the REDB resources first and the REC second. Afterwards, you may delete the project. </p> <h3 id="rec-extralabels-are-not-applied-to-pvcs-on-k8s-versions-115-or-older-red-51921"> REC extraLabels are not applied to PVCs on K8s versions 1.15 or older (RED-51921) </h3> <p> In K8s 1.15 or older, the PVC labels come from the match selectors and not the PVC templates. As such, these versions cannot support PVC labels. If this feature is required, the only fix is to upgrade the K8s cluster to a newer version. </p> <h3 id="hashicorp-vault-integration---no-support-for-gesher-red-55080"> Hashicorp Vault integration - no support for Gesher (RED-55080) </h3> <p> There is no workaround at this time </p> <h3 id="rec-might-report-error-states-on-initial-startup-red-61707"> REC might report error states on initial startup (RED-61707) </h3> <p> There is no workaround at this time except to ignore the errors. </p> <h3 id="pvc-size-issues-when-using-decimal-value-in-spec-red-62132"> PVC size issues when using decimal value in spec (RED-62132) </h3> <p> The workaround for this issue is to make sure you use integer values for the PVC size. </p> <h3 id="following-old-revision-of-quick-start-guide-causes-issues-creating-an-redb-due-to-unrecognized-memory-field-name"> Following old revision of quick start guide causes issues creating an REDB due to unrecognized memory field name </h3> <p> The workaround is to use the newer (current) revision of the quick start document available online. </p> <h2 id="compatibility-notes"> Compatibility Notes </h2> <p> See <a href="/docs/latest/operate/kubernetes/reference/supported_k8s_distributions/"> Supported Kubernetes distributions </a> for the full list of supported distributions. </p> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/kubernetes/release-notes/k8s-6-2-8-15-2022-01/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/7.4/installing-upgrading/.html
<section class="prose w-full py-12 max-w-none"> <h1> Install, set up, and upgrade Redis Enterprise Software </h1> <p class="text-lg -mt-5 mb-10"> Learn how to install, set up, and upgrade Redis Enterprise Software. </p> <p> You can run self-managed Redis Enterprise Software in an on-premises data center or on your preferred cloud platform. </p> <p> If you prefer a fully managed Redis database-as-a-service, available on major public cloud services, consider setting up a <a href="/docs/latest/operate/rc/"> Redis Cloud </a> subscription. You can <a href="https://redis.io/try-free/"> try Redis Cloud </a> for free. </p> <h2 id="quickstarts"> Quickstarts </h2> <p> If you want to try out Redis Enterprise Software, see the following quickstarts: </p> <ul> <li> <p> <a href="/docs/latest/operate/rs/7.4/installing-upgrading/quickstarts/redis-enterprise-software-quickstart/"> Redis Enterprise Software quickstart </a> </p> </li> <li> <p> <a href="/docs/latest/operate/rs/7.4/installing-upgrading/quickstarts/docker-quickstart/"> Docker quickstart for Redis Enterprise Software </a> </p> </li> </ul> <h2 id="install-redis-enterprise-software"> Install Redis Enterprise Software </h2> <p> To install Redis Enterprise Software on a <a href="/docs/latest/operate/rs/7.4/installing-upgrading/install/plan-deployment/supported-platforms/"> supported platform </a> , you need to: </p> <ol> <li> <p> <a href="/docs/latest/operate/rs/7.4/installing-upgrading/install/plan-deployment/"> Plan your deployment </a> . </p> </li> <li> <p> <a href="/docs/latest/operate/rs/7.4/installing-upgrading/install/prepare-install/"> Prepare to install </a> . </p> </li> <li> <p> <a href="/docs/latest/operate/rs/7.4/installing-upgrading/install/"> Perform the install </a> . </p> </li> </ol> <p> Depending on your needs, you may also want to <a href="#more-info-and-options"> customize the installation </a> . </p> <h2 id="upgrade-existing-deployment"> Upgrade existing deployment </h2> <p> If you already installed Redis Enterprise Software, you can: </p> <ul> <li> <p> <a href="/docs/latest/operate/rs/7.4/installing-upgrading/upgrading/upgrade-cluster/"> Upgrade a cluster </a> </p> </li> <li> <p> <a href="/docs/latest/operate/rs/7.4/installing-upgrading/upgrading/upgrade-database/"> Upgrade a database </a> </p> </li> <li> <p> <a href="/docs/latest/operate/rs/7.4/installing-upgrading/upgrading/upgrade-active-active/"> Upgrade an Active-Active database </a> </p> </li> </ul> <h2 id="uninstall-redis-enterprise-software"> Uninstall Redis Enterprise Software </h2> <ul> <li> <a href="/docs/latest/operate/rs/7.4/installing-upgrading/uninstalling/"> Uninstall existing deployment </a> </li> </ul> <h2 id="more-info-and-options"> More info and options </h2> <p> More information is available to help with customization and related questions: </p> <ul> <li> <a href="/docs/latest/operate/rs/7.4/installing-upgrading/configuring/centos-rhel-firewall/"> CentOS/RHEL firewall configuration </a> </li> <li> <a href="/docs/latest/operate/rs/7.4/installing-upgrading/configuring/change-location-socket-files/"> Change socket file location </a> </li> <li> <a href="/docs/latest/operate/rs/7.4/networking/cluster-dns/"> Cluster DNS configuration </a> </li> <li> <a href="/docs/latest/operate/rs/7.4/networking/cluster-lba-setup/"> Cluster load balancer setup </a> </li> <li> <a href="/docs/latest/operate/rs/7.4/installing-upgrading/install/plan-deployment/file-locations/"> File locations </a> </li> <li> <a href="/docs/latest/operate/rs/7.4/installing-upgrading/configuring/linux-swap/"> Linux swap space configuration </a> </li> <li> <a href="/docs/latest/operate/rs/7.4/networking/mdns/"> mDNS client prerequisites </a> </li> <li> <a href="/docs/latest/operate/rs/7.4/installing-upgrading/install/customize-user-and-group/"> User and group ownership </a> </li> </ul> <h2 id="next-steps"> Next steps </h2> <p> After you install Redis Enterprise Software and set up your cluster, you can: </p> <ul> <li> <p> <a href="/docs/latest/operate/rs/7.4/security/access-control/create-users/"> Add users </a> to the cluster with specific permissions. To begin, start with <a href="/docs/latest/operate/rs/7.4/security/access-control/"> Access control </a> . </p> </li> <li> <p> <a href="/docs/latest/operate/rs/7.4/databases/create/"> Create databases </a> to use with your applications. </p> </li> </ul> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/installing-upgrading/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/integrate/write-behind/data-transformation/.html
<section class="prose w-full py-12 max-w-none"> <h1> Data transformation </h1> <p> The key functionality that Write-behind performs is mapping the data coming from <a href="https://debezium.io/documentation/reference/stable/operations/debezium-server.html"> Debezium Server </a> (representing a Source Database row data or row state change) into a Redis key with a value of <a href="/docs/latest/develop/data-types/hashes/"> Hash </a> or <a href="/docs/latest/develop/data-types/json/"> JSON </a> . There are two types of data transformations in Write-behind: </p> <ol> <li> <p> By default, each source row is converted into one hash or one JSON key in Redis. This conversion uses the Debezium schema-based conversion. The incoming data includes the schema and Write-behind uses a set of handlers to automatically convert each source column to a Redis Hash field or JSON type based on the Debezium type in the schema. See <a href="/docs/latest/integrate/write-behind/reference/data-types-conversion/"> data type conversion </a> for a full reference on these conversions. </p> </li> <li> <p> If the user wants to add or modify this default mapping, Write-behind provides declarative data transformations. These transformations are represented in YAML files. Each file contains a job, which is a set of transformations per source table. See <a href="/docs/latest/integrate/write-behind/data-transformation/data-transformation-pipeline/"> declarative transformations </a> for more information. </p> </li> </ol> <a href="/docs/latest/images/rdi/data-transformation-flow.png" sdata-lightbox="/images/rdi/data-transformation-flow.png"> <img src="/docs/latest/images/rdi/data-transformation-flow.png"/> </a> <h2 id="more-info"> More info </h2> <nav> <a href="/docs/latest/integrate/write-behind/data-transformation/data-transformation-pipeline/"> Data transformation pipeline </a> <p> Learn how to transform data to Redis types </p> <a href="/docs/latest/integrate/write-behind/data-transformation/transformation-examples/"> Write-behind transformation examples </a> <p> See examples of write-behind transform job configurations </p> </nav> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/integrate/write-behind/data-transformation/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/develop/interact/search-and-query/search/vectors/.html
<section class="prose w-full py-12"> <h1> Vectors </h1> <p class="text-lg -mt-5 mb-10"> Learn how to use vector fields and perform vector searches in Redis </p> <p> Redis includes a <a href="https://redis.io/blog/benchmarking-results-for-vector-databases/"> high-performance vector database </a> that lets you perform semantic searches over vector embeddings. You can augment these searches with filtering over text, numerical, geospatial, and tag metadata. </p> <p> To quickly get started, check out the <a href="/docs/latest/develop/get-started/vector-database"> Redis vector quickstart guide </a> and the <a href="https://github.com/redis-developer/redis-ai-resources"> Redis AI Resources </a> Github repo. </p> <h2 id="overview"> Overview </h2> <ol> <li> <a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/vectors#create-a-vector-index"> <strong> Create a vector index </strong> </a> : Redis maintains a secondary index over your data with a defined schema (including vector fields and metadata). Redis supports <a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/vectors#flat-index"> <code> FLAT </code> </a> and <a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/vectors#hnsw-index"> <code> HNSW </code> </a> vector index types. </li> <li> <a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/vectors#store-and-update-vectors"> <strong> Store and update vectors </strong> </a> : Redis stores vectors and metadata in hashes or JSON objects. </li> <li> <a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/vectors#search-with-vectors"> <strong> Search with vectors </strong> </a> : Redis supports several advanced querying strategies with vector fields including k-nearest neighbor ( <a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/vectors#knn-vector-search"> KNN </a> ), <a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/vectors#vector-range-queries"> vector range queries </a> , and <a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/vectors#filters"> metadata filters </a> . </li> <li> <a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/vectors#runtime-query-params"> <strong> Configure vector queries at runtime </strong> </a> . </li> <li> <a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/vectors#vector-search-examples"> <strong> Vector search examples </strong> </a> : Explore several vector search examples that cover different use cases and techniques. </li> </ol> <h2 id="create-a-vector-index"> Create a vector index </h2> <p> When you define the schema for an index, you can include one or more vector fields as shown below. </p> <p> <strong> Syntax </strong> </p> <pre tabindex="0"><code>FT.CREATE &lt;index_name&gt; ON &lt;storage_type&gt; PREFIX 1 &lt;key_prefix&gt; SCHEMA ... &lt;field_name&gt; VECTOR &lt;algorithm&gt; &lt;index_attribute_count&gt; &lt;index_attribute_name&gt; &lt;index_attribute_value&gt; [&lt;index_attribute_name&gt; &lt;index_attribute_value&gt; ...] </code></pre> <p> Refer to the full <a href="/docs/latest/develop/interact/search-and-query/indexing/"> indexing </a> documentation for additional fields, options, and noted limitations. </p> <p> <strong> Parameters </strong> </p> <table> <thead> <tr> <th style="text-align:left"> Parameter </th> <th style="text-align:left"> Description </th> </tr> </thead> <tbody> <tr> <td style="text-align:left"> <code> index_name </code> </td> <td style="text-align:left"> Name of the index. </td> </tr> <tr> <td style="text-align:left"> <code> storage_type </code> </td> <td style="text-align:left"> Storage option ( <code> HASH </code> or <code> JSON </code> ). </td> </tr> <tr> <td style="text-align:left"> <code> prefix </code> (optional) </td> <td style="text-align:left"> Key prefix used to select which keys should be indexed. Defaults to all keys if omitted. </td> </tr> <tr> <td style="text-align:left"> <code> field_name </code> </td> <td style="text-align:left"> Name of the vector field. </td> </tr> <tr> <td style="text-align:left"> <code> algorithm </code> </td> <td style="text-align:left"> Vector index algorithm ( <code> FLAT </code> or <code> HNSW </code> ). </td> </tr> <tr> <td style="text-align:left"> <code> index_attribute_count </code> </td> <td style="text-align:left"> Number of vector field attributes. </td> </tr> <tr> <td style="text-align:left"> <code> index_attribute_name </code> </td> <td style="text-align:left"> Vector field attribute name. </td> </tr> <tr> <td style="text-align:left"> <code> index_attribute_value </code> </td> <td style="text-align:left"> Vector field attribute value. </td> </tr> </tbody> </table> <h3 id="flat-index"> FLAT index </h3> <p> Choose the <code> FLAT </code> index when you have small datasets (&lt; 1M vectors) or when perfect search accuracy is more important than search latency. </p> <p> <strong> Required attributes </strong> </p> <table> <thead> <tr> <th style="text-align:left"> Attribute </th> <th style="text-align:left"> Description </th> </tr> </thead> <tbody> <tr> <td style="text-align:left"> <code> TYPE </code> </td> <td style="text-align:left"> Vector type ( <code> BFLOAT16 </code> , <code> FLOAT16 </code> , <code> FLOAT32 </code> , <code> FLOAT64 </code> ). <code> BFLOAT16 </code> and <code> FLOAT16 </code> require v2.10 or later. </td> </tr> <tr> <td style="text-align:left"> <code> DIM </code> </td> <td style="text-align:left"> The width, or number of dimensions, of the vector embeddings stored in this field. In other words, the number of floating point elements comprising the vector. <code> DIM </code> must be a positive integer. The vector used to query this field must have the exact dimensions as the field itself. </td> </tr> <tr> <td style="text-align:left"> <code> DISTANCE_METRIC </code> </td> <td style="text-align:left"> Distance metric ( <code> L2 </code> , <code> IP </code> , <code> COSINE </code> ). </td> </tr> </tbody> </table> <p> <strong> Example </strong> </p> <pre tabindex="0"><code>FT.CREATE documents ON HASH PREFIX 1 docs: SCHEMA doc_embedding VECTOR FLAT 6 TYPE FLOAT32 DIM 1536 DISTANCE_METRIC COSINE </code></pre> <p> In the example above, an index named <code> documents </code> is created over hashes with the key prefix <code> docs: </code> and a <code> FLAT </code> vector field named <code> doc_embedding </code> with three index attributes: <code> TYPE </code> , <code> DIM </code> , and <code> DISTANCE_METRIC </code> . </p> <h3 id="hnsw-index"> HNSW index </h3> <p> <code> HNSW </code> , or hierarchical navigable small world, is an approximate nearest neighbors algorithm that uses a multi-layered graph to make vector search more scalable. </p> <ul> <li> The lowest layer contains all data points, and each higher layer contains a subset, forming a hierarchy. </li> <li> At runtime, the search traverses the graph on each layer from top to bottom, finding the local minima before dropping to the subsequent layer. </li> </ul> <p> Choose the <code> HNSW </code> index type when you have larger datasets (&gt; 1M documents) or when search performance and scalability are more important than perfect search accuracy. </p> <p> <strong> Required attributes </strong> </p> <table> <thead> <tr> <th style="text-align:left"> Attribute </th> <th style="text-align:left"> Description </th> </tr> </thead> <tbody> <tr> <td style="text-align:left"> <code> TYPE </code> </td> <td style="text-align:left"> Vector type ( <code> BFLOAT16 </code> , <code> FLOAT16 </code> , <code> FLOAT32 </code> , <code> FLOAT64 </code> ). <code> BFLOAT16 </code> and <code> FLOAT16 </code> require v2.10 or later. </td> </tr> <tr> <td style="text-align:left"> <code> DIM </code> </td> <td style="text-align:left"> The width, or number of dimensions, of the vector embeddings stored in this field. In other words, the number of floating point elements comprising the vector. <code> DIM </code> must be a positive integer. The vector used to query this field must have the exact dimensions as the field itself. </td> </tr> <tr> <td style="text-align:left"> <code> DISTANCE_METRIC </code> </td> <td style="text-align:left"> Distance metric ( <code> L2 </code> , <code> IP </code> , <code> COSINE </code> ). </td> </tr> </tbody> </table> <p> <strong> Optional attributes </strong> </p> <p> <a href="https://arxiv.org/ftp/arxiv/papers/1603/1603.09320.pdf"> <code> HNSW </code> </a> supports a number of additional parameters to tune the accuracy of the queries, while trading off performance. </p> <table> <thead> <tr> <th style="text-align:left"> Attribute </th> <th style="text-align:left"> Description </th> </tr> </thead> <tbody> <tr> <td style="text-align:left"> <code> M </code> </td> <td style="text-align:left"> Max number of outgoing edges (connections) for each node in a graph layer. On layer zero, the max number of connections will be <code> 2 * M </code> . Higher values increase accuracy, but also increase memory usage and index build time. The default is 16. </td> </tr> <tr> <td style="text-align:left"> <code> EF_CONSTRUCTION </code> </td> <td style="text-align:left"> Max number of connected neighbors to consider during graph building. Higher values increase accuracy, but also increase index build time. The default is 200. </td> </tr> <tr> <td style="text-align:left"> <code> EF_RUNTIME </code> </td> <td style="text-align:left"> Max top candidates during KNN search. Higher values increase accuracy, but also increase search latency. The default is 10. </td> </tr> <tr> <td style="text-align:left"> <code> EPSILON </code> </td> <td style="text-align:left"> Relative factor that sets the boundaries in which a range query may search for candidates. That is, vector candidates whose distance from the query vector is <code> radius * (1 + EPSILON) </code> are potentially scanned, allowing more extensive search and more accurate results, at the expense of run time. The default is 0.01. </td> </tr> </tbody> </table> <p> <strong> Example </strong> </p> <pre tabindex="0"><code>FT.CREATE documents ON HASH PREFIX 1 docs: SCHEMA doc_embedding VECTOR HNSW 10 TYPE FLOAT64 DIM 1536 DISTANCE_METRIC COSINE M 40 EF_CONSTRUCTION 250 </code></pre> <p> In the example above, an index named <code> documents </code> is created over hashes with the key prefix <code> docs: </code> and an <code> HNSW </code> vector field named <code> doc_embedding </code> with five index attributes: <code> TYPE </code> , <code> DIM </code> , <code> DISTANCE_METRIC </code> , <code> M </code> , and <code> EF_CONSTRUCTION </code> . </p> <h3 id="distance-metrics"> Distance metrics </h3> <p> Redis supports three popular distance metrics to measure the degree of similarity between two vectors <mjx-container class="MathJax CtxtMenu_Attached_0" ctxtmenu_counter="0" jax="CHTML" style="font-size: 120%; position: relative;" tabindex="0"> <mjx-math aria-hidden="true" class="MJX-TEX"> <mjx-mi class="mjx-i"> <mjx-c class="mjx-c1D462 TEX-I"> </mjx-c> </mjx-mi> </mjx-math> <mjx-assistive-mml display="inline" unselectable="on"> <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi> u </mi> </math> </mjx-assistive-mml> </mjx-container> , <mjx-container class="MathJax CtxtMenu_Attached_0" ctxtmenu_counter="1" jax="CHTML" style="font-size: 120%; position: relative;" tabindex="0"> <mjx-math aria-hidden="true" class="MJX-TEX"> <mjx-mi class="mjx-i"> <mjx-c class="mjx-c1D463 TEX-I"> </mjx-c> </mjx-mi> </mjx-math> <mjx-assistive-mml display="inline" unselectable="on"> <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi> v </mi> </math> </mjx-assistive-mml> </mjx-container> <mjx-container class="MathJax CtxtMenu_Attached_0" ctxtmenu_counter="2" jax="CHTML" style="font-size: 120%; position: relative;" tabindex="0"> <mjx-math aria-hidden="true" class="MJX-TEX"> <mjx-mo class="mjx-n"> <mjx-c class="mjx-c2208"> </mjx-c> </mjx-mo> <mjx-msup space="4"> <mjx-texatom texclass="ORD"> <mjx-mi class="mjx-ds mjx-b"> <mjx-c class="mjx-c211D TEX-A"> </mjx-c> </mjx-mi> </mjx-texatom> <mjx-script style="vertical-align: 0.363em;"> <mjx-mi class="mjx-i" size="s"> <mjx-c class="mjx-c1D45B TEX-I"> </mjx-c> </mjx-mi> </mjx-script> </mjx-msup> </mjx-math> <mjx-assistive-mml display="inline" unselectable="on"> <math xmlns="http://www.w3.org/1998/Math/MathML"> <mo> ∈ </mo> <msup> <mrow data-mjx-texclass="ORD"> <mi mathvariant="double-struck"> R </mi> </mrow> <mi> n </mi> </msup> </math> </mjx-assistive-mml> </mjx-container> , where <mjx-container class="MathJax CtxtMenu_Attached_0" ctxtmenu_counter="3" jax="CHTML" style="font-size: 120%; position: relative;" tabindex="0"> <mjx-math aria-hidden="true" class="MJX-TEX"> <mjx-mi class="mjx-i"> <mjx-c class="mjx-c1D45B TEX-I"> </mjx-c> </mjx-mi> </mjx-math> <mjx-assistive-mml display="inline" unselectable="on"> <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi> n </mi> </math> </mjx-assistive-mml> </mjx-container> is the length of the vectors: </p> <table> <thead> <tr> <th style="text-align:left"> Distance metric </th> <th style="text-align:left"> Description </th> <th style="text-align:left"> Mathematical representation </th> </tr> </thead> <tbody> <tr> <td style="text-align:left"> <code> L2 </code> </td> <td style="text-align:left"> Euclidean distance between two vectors. </td> <td style="text-align:left"> <mjx-container class="MathJax CtxtMenu_Attached_0" ctxtmenu_counter="4" jax="CHTML" style="font-size: 119.9%; position: relative;" tabindex="0"> <mjx-math aria-hidden="true" class="MJX-TEX"> <mjx-mi class="mjx-i"> <mjx-c class="mjx-c1D451 TEX-I"> </mjx-c> </mjx-mi> <mjx-mo class="mjx-n"> <mjx-c class="mjx-c28"> </mjx-c> </mjx-mo> <mjx-mi class="mjx-i"> <mjx-c class="mjx-c1D462 TEX-I"> </mjx-c> </mjx-mi> <mjx-mo class="mjx-n"> <mjx-c class="mjx-c2C"> </mjx-c> </mjx-mo> <mjx-mi class="mjx-i" space="2"> <mjx-c class="mjx-c1D463 TEX-I"> </mjx-c> </mjx-mi> <mjx-mo class="mjx-n"> <mjx-c class="mjx-c29"> </mjx-c> </mjx-mo> <mjx-mo class="mjx-n" space="4"> <mjx-c class="mjx-c3D"> </mjx-c> </mjx-mo> <mjx-msqrt space="4"> <mjx-sqrt> <mjx-surd> <mjx-mo class="mjx-s4"> <mjx-c class="mjx-c221A TEX-S4"> </mjx-c> </mjx-mo> </mjx-surd> <mjx-box style="padding-top: 0.103em;"> <mjx-mstyle> <mjx-munderover> <mjx-over style="padding-bottom: 0.192em; padding-left: 0.51em;"> <mjx-mi class="mjx-i" size="s"> <mjx-c class="mjx-c1D45B TEX-I"> </mjx-c> </mjx-mi> </mjx-over> <mjx-box> <mjx-munder> <mjx-row> <mjx-base> <mjx-mo class="mjx-lop"> <mjx-c class="mjx-c2211 TEX-S2"> </mjx-c> </mjx-mo> </mjx-base> </mjx-row> <mjx-row> <mjx-under style="padding-top: 0.167em; padding-left: 0.148em;"> <mjx-texatom size="s" texclass="ORD"> <mjx-mi class="mjx-i"> <mjx-c class="mjx-c1D456 TEX-I"> </mjx-c> </mjx-mi> <mjx-mo class="mjx-n"> <mjx-c class="mjx-c3D"> </mjx-c> </mjx-mo> <mjx-mn class="mjx-n"> <mjx-c class="mjx-c31"> </mjx-c> </mjx-mn> </mjx-texatom> </mjx-under> </mjx-row> </mjx-munder> </mjx-box> </mjx-munderover> <mjx-texatom space="2" texclass="ORD"> <mjx-mo class="mjx-n"> <mjx-c class="mjx-c28"> </mjx-c> </mjx-mo> <mjx-msub> <mjx-mi class="mjx-i"> <mjx-c class="mjx-c1D462 TEX-I"> </mjx-c> </mjx-mi> <mjx-script style="vertical-align: -0.15em;"> <mjx-mi class="mjx-i" size="s"> <mjx-c class="mjx-c1D456 TEX-I"> </mjx-c> </mjx-mi> </mjx-script> </mjx-msub> <mjx-mo class="mjx-n" space="3"> <mjx-c class="mjx-c2212"> </mjx-c> </mjx-mo> <mjx-msub space="3"> <mjx-mi class="mjx-i"> <mjx-c class="mjx-c1D463 TEX-I"> </mjx-c> </mjx-mi> <mjx-script style="vertical-align: -0.15em;"> <mjx-mi class="mjx-i" size="s"> <mjx-c class="mjx-c1D456 TEX-I"> </mjx-c> </mjx-mi> </mjx-script> </mjx-msub> <mjx-msup> <mjx-mo class="mjx-n"> <mjx-c class="mjx-c29"> </mjx-c> </mjx-mo> <mjx-script style="vertical-align: 0.413em;"> <mjx-mn class="mjx-n" size="s"> <mjx-c class="mjx-c32"> </mjx-c> </mjx-mn> </mjx-script> </mjx-msup> </mjx-texatom> </mjx-mstyle> </mjx-box> </mjx-sqrt> </mjx-msqrt> </mjx-math> <mjx-assistive-mml display="inline" unselectable="on"> <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi> d </mi> <mo stretchy="false"> ( </mo> <mi> u </mi> <mo> , </mo> <mi> v </mi> <mo stretchy="false"> ) </mo> <mo> = </mo> <msqrt> <mstyle displaystyle="true" scriptlevel="0"> <munderover> <mo data-mjx-texclass="OP"> ∑ </mo> <mrow data-mjx-texclass="ORD"> <mi> i </mi> <mo> = </mo> <mn> 1 </mn> </mrow> <mi> n </mi> </munderover> <mrow data-mjx-texclass="ORD"> <mo stretchy="false"> ( </mo> <msub> <mi> u </mi> <mi> i </mi> </msub> <mo> − </mo> <msub> <mi> v </mi> <mi> i </mi> </msub> <msup> <mo stretchy="false"> ) </mo> <mn> 2 </mn> </msup> </mrow> </mstyle> </msqrt> </math> </mjx-assistive-mml> </mjx-container> </td> </tr> <tr> <td style="text-align:left"> <code> IP </code> </td> <td style="text-align:left"> Inner product of two vectors. </td> <td style="text-align:left"> <mjx-container class="MathJax CtxtMenu_Attached_0" ctxtmenu_counter="5" jax="CHTML" style="font-size: 119.9%; position: relative;" tabindex="0"> <mjx-math aria-hidden="true" class="MJX-TEX"> <mjx-mi class="mjx-i"> <mjx-c class="mjx-c1D451 TEX-I"> </mjx-c> </mjx-mi> <mjx-mo class="mjx-n"> <mjx-c class="mjx-c28"> </mjx-c> </mjx-mo> <mjx-mi class="mjx-i"> <mjx-c class="mjx-c1D462 TEX-I"> </mjx-c> </mjx-mi> <mjx-mo class="mjx-n"> <mjx-c class="mjx-c2C"> </mjx-c> </mjx-mo> <mjx-mi class="mjx-i" space="2"> <mjx-c class="mjx-c1D463 TEX-I"> </mjx-c> </mjx-mi> <mjx-mo class="mjx-n"> <mjx-c class="mjx-c29"> </mjx-c> </mjx-mo> <mjx-mo class="mjx-n" space="4"> <mjx-c class="mjx-c3D"> </mjx-c> </mjx-mo> <mjx-mn class="mjx-n" space="4"> <mjx-c class="mjx-c31"> </mjx-c> </mjx-mn> <mjx-mo class="mjx-n" space="3"> <mjx-c class="mjx-c2212"> </mjx-c> </mjx-mo> <mjx-mi class="mjx-i" space="3"> <mjx-c class="mjx-c1D462 TEX-I"> </mjx-c> </mjx-mi> <mjx-mo class="mjx-n" space="3"> <mjx-c class="mjx-c22C5"> </mjx-c> </mjx-mo> <mjx-mi class="mjx-i" space="3"> <mjx-c class="mjx-c1D463 TEX-I"> </mjx-c> </mjx-mi> </mjx-math> <mjx-assistive-mml display="inline" unselectable="on"> <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi> d </mi> <mo stretchy="false"> ( </mo> <mi> u </mi> <mo> , </mo> <mi> v </mi> <mo stretchy="false"> ) </mo> <mo> = </mo> <mn> 1 </mn> <mo> − </mo> <mi> u </mi> <mo> ⋅ </mo> <mi> v </mi> </math> </mjx-assistive-mml> </mjx-container> </td> </tr> <tr> <td style="text-align:left"> <code> COSINE </code> </td> <td style="text-align:left"> Cosine distance of two vectors. </td> <td style="text-align:left"> <mjx-container class="MathJax CtxtMenu_Attached_0" ctxtmenu_counter="6" jax="CHTML" style="font-size: 119.9%; position: relative;" tabindex="0"> <mjx-math aria-hidden="true" class="MJX-TEX"> <mjx-mi class="mjx-i"> <mjx-c class="mjx-c1D451 TEX-I"> </mjx-c> </mjx-mi> <mjx-mo class="mjx-n"> <mjx-c class="mjx-c28"> </mjx-c> </mjx-mo> <mjx-mi class="mjx-i"> <mjx-c class="mjx-c1D462 TEX-I"> </mjx-c> </mjx-mi> <mjx-mo class="mjx-n"> <mjx-c class="mjx-c2C"> </mjx-c> </mjx-mo> <mjx-mi class="mjx-i" space="2"> <mjx-c class="mjx-c1D463 TEX-I"> </mjx-c> </mjx-mi> <mjx-mo class="mjx-n"> <mjx-c class="mjx-c29"> </mjx-c> </mjx-mo> <mjx-mo class="mjx-n" space="4"> <mjx-c class="mjx-c3D"> </mjx-c> </mjx-mo> <mjx-mn class="mjx-n" space="4"> <mjx-c class="mjx-c31"> </mjx-c> </mjx-mn> <mjx-mo class="mjx-n" space="3"> <mjx-c class="mjx-c2212"> </mjx-c> </mjx-mo> <mjx-mfrac space="3"> <mjx-frac> <mjx-num> <mjx-nstrut> </mjx-nstrut> <mjx-mrow size="s"> <mjx-mi class="mjx-i"> <mjx-c class="mjx-c1D462 TEX-I"> </mjx-c> </mjx-mi> <mjx-mo class="mjx-n"> <mjx-c class="mjx-c22C5"> </mjx-c> </mjx-mo> <mjx-mi class="mjx-i"> <mjx-c class="mjx-c1D463 TEX-I"> </mjx-c> </mjx-mi> </mjx-mrow> </mjx-num> <mjx-dbox> <mjx-dtable> <mjx-line> </mjx-line> <mjx-row> <mjx-den> <mjx-dstrut> </mjx-dstrut> <mjx-mrow size="s"> <mjx-mo class="mjx-n"> <mjx-c class="mjx-c2016"> </mjx-c> </mjx-mo> <mjx-mi class="mjx-i"> <mjx-c class="mjx-c1D462 TEX-I"> </mjx-c> </mjx-mi> <mjx-mo class="mjx-n"> <mjx-c class="mjx-c2016"> </mjx-c> </mjx-mo> <mjx-mo class="mjx-n"> <mjx-c class="mjx-c2016"> </mjx-c> </mjx-mo> <mjx-mi class="mjx-i"> <mjx-c class="mjx-c1D463 TEX-I"> </mjx-c> </mjx-mi> <mjx-mo class="mjx-n"> <mjx-c class="mjx-c2016"> </mjx-c> </mjx-mo> </mjx-mrow> </mjx-den> </mjx-row> </mjx-dtable> </mjx-dbox> </mjx-frac> </mjx-mfrac> </mjx-math> <mjx-assistive-mml display="inline" unselectable="on"> <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi> d </mi> <mo stretchy="false"> ( </mo> <mi> u </mi> <mo> , </mo> <mi> v </mi> <mo stretchy="false"> ) </mo> <mo> = </mo> <mn> 1 </mn> <mo> − </mo> <mfrac> <mrow> <mi> u </mi> <mo> ⋅ </mo> <mi> v </mi> </mrow> <mrow> <mo data-mjx-texclass="OPEN" fence="false" stretchy="false"> ‖ </mo> <mi> u </mi> <mo data-mjx-texclass="CLOSE" fence="false" stretchy="false"> ‖ </mo> <mo data-mjx-texclass="OPEN" fence="false" stretchy="false"> ‖ </mo> <mi> v </mi> <mo data-mjx-texclass="CLOSE" fence="false" stretchy="false"> ‖ </mo> </mrow> </mfrac> </math> </mjx-assistive-mml> </mjx-container> </td> </tr> </tbody> </table> <p> The above metrics calculate distance between two vectors, where the smaller the value is, the closer the two vectors are in the vector space. </p> <h2 id="store-and-update-vectors"> Store and update vectors </h2> <p> On index creation, the <code> &lt;storage_type&gt; </code> dictates how vector and metadata are structured and loaded into Redis. </p> <h3 id="hash"> Hash </h3> <p> Store or update vectors and any metadata in <a href="/docs/latest/develop/data-types/hashes/"> hashes </a> using the <a href="/docs/latest/commands/hset/"> <code> HSET </code> </a> command. </p> <p> <strong> Example </strong> </p> <pre tabindex="0"><code>HSET docs:01 doc_embedding &lt;vector_bytes&gt; category sports </code></pre> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Tip: </div> Hash values are stored as binary-safe strings. The value <code> &lt;vector_bytes&gt; </code> represents the vector's underlying memory buffer. </div> </div> <p> A common method for converting vectors to bytes uses the <a href="https://redis-py.readthedocs.io/en/stable/examples/search_vector_similarity_examples.html"> redis-py </a> client library and the Python <a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.tobytes.html"> NumPy </a> library. </p> <p> <strong> Example </strong> </p> <div class="highlight"> <pre class="chroma"><code class="language-py" data-lang="py"><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span> </span></span><span class="line"><span class="cl"><span class="kn">from</span> <span class="nn">redis</span> <span class="kn">import</span> <span class="n">Redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">redis_client</span> <span class="o">=</span> <span class="n">Redis</span><span class="p">(</span><span class="n">host</span><span class="o">=</span><span class="s1">'localhost'</span><span class="p">,</span> <span class="n">port</span><span class="o">=</span><span class="mi">6379</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="c1"># Create a FLOAT32 vector</span> </span></span><span class="line"><span class="cl"><span class="n">vector</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mf">0.34</span><span class="p">,</span> <span class="mf">0.63</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.54</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.69</span><span class="p">,</span> <span class="mf">0.98</span><span class="p">,</span> <span class="mf">0.61</span><span class="p">],</span> <span class="n">dtype</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">float32</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="c1"># Convert vector to bytes</span> </span></span><span class="line"><span class="cl"><span class="n">vector_bytes</span> <span class="o">=</span> <span class="n">vector</span><span class="o">.</span><span class="n">tobytes</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="c1"># Use the Redis client to store the vector bytes and metadata at a specified key</span> </span></span><span class="line"><span class="cl"><span class="n">redis_client</span><span class="o">.</span><span class="n">hset</span><span class="p">(</span><span class="s1">'docs:01'</span><span class="p">,</span> <span class="n">mapping</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"vector"</span><span class="p">:</span> <span class="n">vector_bytes</span><span class="p">,</span> <span class="s2">"category"</span><span class="p">:</span> <span class="s2">"sports"</span><span class="p">})</span> </span></span></code></pre> </div> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Tip: </div> The vector blob size must match the dimension and float type of the vector field specified in the index's schema; otherwise, indexing will fail. </div> </div> <h3 id="json"> JSON </h3> <p> You can store or update vectors and any associated metadata in <a href="/docs/latest/develop/data-types/json/"> JSON </a> using the <a href="/docs/latest/commands/json.set/"> <code> JSON.SET </code> </a> command. </p> <p> To store vectors in Redis as JSON, you store the vector as a JSON array of floats. Note that this differs from vector storage in Redis hashes, which are instead stored as raw bytes. </p> <p> <strong> Example </strong> </p> <pre tabindex="0"><code>JSON.SET docs:01 $ '{"doc_embedding":[0.34,0.63,-0.54,-0.69,0.98,0.61], "category": "sports"}' </code></pre> <p> One of the benefits of JSON is schema flexibility. As of v2.6.1, JSON supports multi-value indexing. This allows you to index multiple vectors under the same <a href="/docs/latest/develop/data-types/json/path/"> JSONPath </a> . </p> <p> Here are some examples of multi-value indexing with vectors: </p> <p> <strong> Multi-value indexing example </strong> </p> <pre tabindex="0"><code>JSON.SET docs:01 $ '{"doc_embedding":[[1,2,3,4], [5,6,7,8]]}' JSON.SET docs:01 $ '{"chunk1":{"doc_embedding":[1,2,3,4]}, "chunk2":{"doc_embedding":[5,6,7,8]}}' </code></pre> <p> Additional information and examples are available in the <a href="/docs/latest/develop/interact/search-and-query/indexing/#index-json-arrays-as-vector"> Indexing JSON documents </a> section. </p> <h2 id="search-with-vectors"> Search with vectors </h2> <p> You can run vector search queries with the <a href="/docs/latest/commands/ft.search/"> <code> FT.SEARCH </code> </a> or <a href="/docs/latest/commands/ft.aggregate/"> <code> FT.AGGREGATE </code> </a> commands. </p> <p> To issue a vector search query with <code> FT.SEARCH </code> , you must set the <code> DIALECT </code> option to &gt;= <code> 2 </code> . See the <a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/dialects/"> dialects documentation </a> for more information. </p> <h3 id="knn-vector-search"> KNN vector search </h3> <p> KNN vector search finds the top k nearest neighbors to a query vector. It has the following syntax: </p> <p> <strong> Syntax </strong> </p> <pre tabindex="0"><code>FT.SEARCH &lt;index_name&gt; &lt;primary_filter_query&gt;=&gt;[KNN &lt;top_k&gt; @&lt;vector_field&gt; $&lt;vector_blob_param&gt; $&lt;vector_query_params&gt; AS &lt;distance_field&gt;] PARAMS &lt;query_params_count&gt; [$&lt;vector_blob_param&gt; &lt;vector_blob&gt; &lt;query_param_name&gt; &lt;query_param_value&gt; ...] SORTBY &lt;distance_field&gt; DIALECT 4 </code></pre> <p> <strong> Parameters </strong> </p> <table> <thead> <tr> <th style="text-align:left"> Parameter </th> <th style="text-align:left"> Description </th> </tr> </thead> <tbody> <tr> <td style="text-align:left"> <code> index_name </code> </td> <td style="text-align:left"> Name of the index. </td> </tr> <tr> <td style="text-align:left"> <code> primary_filter_query </code> </td> <td style="text-align:left"> <a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/vectors#filters"> Filter </a> criteria. Use <code> * </code> when no filters are required. </td> </tr> <tr> <td style="text-align:left"> <code> top_k </code> </td> <td style="text-align:left"> Number of nearest neighbors to fetch from the index. </td> </tr> <tr> <td style="text-align:left"> <code> vector_field </code> </td> <td style="text-align:left"> Name of the vector field to search against. </td> </tr> <tr> <td style="text-align:left"> <code> vector_blob_param </code> </td> <td style="text-align:left"> The query vector, passed in as a blob of raw bytes. The blob's byte size must match the vector field's dimensions and type. </td> </tr> <tr> <td style="text-align:left"> <code> vector_query_params </code> (optional) </td> <td style="text-align:left"> An optional section for marking one or more vector query parameters passed through the <code> PARAMS </code> section. Valid parameters should be provided as key-value pairs. See which <a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/vectors#runtime-query-params"> runtime query params </a> are supported for each vector index type. </td> </tr> <tr> <td style="text-align:left"> <code> distance_field </code> (optional) </td> <td style="text-align:left"> The optional distance field name used in the response and/or for sorting. By default, the distance field name is <code> __&lt;vector_field&gt;_score </code> and it can be used for sorting without using <code> AS &lt;distance_field&gt; </code> in the query. </td> </tr> <tr> <td style="text-align:left"> <code> vector_query_params_count </code> </td> <td style="text-align:left"> The number of vector query parameters. </td> </tr> <tr> <td style="text-align:left"> <code> vector_query_param_name </code> </td> <td style="text-align:left"> The name of the vector query parameter. </td> </tr> <tr> <td style="text-align:left"> <code> vector_query_param_value </code> </td> <td style="text-align:left"> The value of the vector query parameter. </td> </tr> </tbody> </table> <p> <strong> Example </strong> </p> <pre tabindex="0"><code>FT.SEARCH documents "*=&gt;[KNN 10 @doc_embedding $BLOB]" PARAMS 2 BLOB "\x12\xa9\xf5\x6c" DIALECT 4 </code></pre> <p> <strong> Use query attributes </strong> </p> <p> Alternatively, as of v2.6, <code> &lt;vector_query_params&gt; </code> and <code> &lt;distance_field&gt; </code> name can be specified in runtime <a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/query_syntax/#query-attributes"> query attributes </a> as shown below. </p> <pre tabindex="0"><code>[KNN &lt;top_k&gt; @&lt;vector_field&gt; $&lt;vector_blob_param&gt;]=&gt;{$yield_distance_as: &lt;distance_field&gt;} </code></pre> <h3 id="vector-range-queries"> Vector range queries </h3> <p> Vector range queries allow you to filter the index using a <code> radius </code> parameter representing the semantic distance between an input query vector and indexed vector fields. This is useful in scenarios when you don't know exactly how many nearest ( <code> top_k </code> ) neighbors to fetch, but you do know how similar the results should be. </p> <p> For example, imagine a fraud or anomaly detection scenario where you aren't sure if there are any matches in the vector index. You can issue a vector range query to quickly check if there are any records of interest in the index within the specified radius. </p> <p> Vector range queries operate slightly different than KNN vector queries: </p> <ul> <li> Vector range queries can appear multiple times in a query as filter criteria. </li> <li> Vector range queries can be a part of the <code> &lt;primary_filter_query&gt; </code> in KNN vector search. </li> </ul> <p> <strong> Syntax </strong> </p> <pre tabindex="0"><code>FT.SEARCH &lt;index_name&gt; @&lt;vector_field&gt;:[VECTOR_RANGE (&lt;radius&gt; | $&lt;radius_param&gt;) $&lt;vector_blob_param&gt; $&lt;vector_query_params&gt;] PARAMS &lt;vector_query_params_count&gt; [&lt;vector_query_param_name&gt; &lt;vector_query_param_value&gt; ...] SORTBY &lt;distance_field&gt; DIALECT 4 </code></pre> <table> <thead> <tr> <th style="text-align:left"> Parameter </th> <th style="text-align:left"> Description </th> </tr> </thead> <tbody> <tr> <td style="text-align:left"> <code> index_name </code> </td> <td style="text-align:left"> Name of the index. </td> </tr> <tr> <td style="text-align:left"> <code> vector_field </code> </td> <td style="text-align:left"> Name of the vector field in the index. </td> </tr> <tr> <td style="text-align:left"> <code> radius </code> or <code> radius_param </code> </td> <td style="text-align:left"> The maximum semantic distance allowed between the query vector and indexed vectors. You can provide the value directly in the query, passed to the <code> PARAMS </code> section, or as a query attribute. </td> </tr> <tr> <td style="text-align:left"> <code> vector_blob_param </code> </td> <td style="text-align:left"> The query vector, passed in as a blob of raw bytes. The blob's byte size must match the vector field's dimensions and type. </td> </tr> <tr> <td style="text-align:left"> <code> vector_query_params </code> (optional) </td> <td style="text-align:left"> An optional section for marking one or more vector query parameters passed through the <code> PARAMS </code> section. Valid parameters should be provided as key-value pairs. See which <a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/vectors#runtime-query-params"> runtime query params </a> are supported for each vector index type. </td> </tr> <tr> <td style="text-align:left"> <code> vector_query_params_count </code> </td> <td style="text-align:left"> The number of vector query parameters. </td> </tr> <tr> <td style="text-align:left"> <code> vector_query_param_name </code> </td> <td style="text-align:left"> The name of the vector query parameter. </td> </tr> <tr> <td style="text-align:left"> <code> vector_query_param_value </code> </td> <td style="text-align:left"> The value of the vector query parameter. </td> </tr> </tbody> </table> <p> <strong> Use query attributes </strong> </p> <p> A vector range query clause can be followed by a query attributes section as follows: </p> <pre tabindex="0"><code>@&lt;vector_field&gt;: [VECTOR_RANGE (&lt;radius&gt; | $&lt;radius_param&gt;) $&lt;vector_blob_param&gt;]=&gt;{$&lt;param&gt;: (&lt;value&gt; | $&lt;value_attribute&gt;); ... } </code></pre> <p> where the relevant parameters in that case are <code> $yield_distance_as </code> and <code> $epsilon </code> . Note that there is no default distance field name in range queries. </p> <h3 id="filters"> Filters </h3> <p> Redis supports vector searches that include filters to narrow the search space based on defined criteria. If your index contains searchable fields (for example, <code> TEXT </code> , <code> TAG </code> , <code> NUMERIC </code> , <code> GEO </code> , <code> GEOSHAPE </code> , and <code> VECTOR </code> ), you can perform vector searches with filters. </p> <p> <strong> Supported filter types </strong> </p> <ul> <li> <a href="https://redis.io/docs/develop/interact/search-and-query/query/exact-match/"> Exact match </a> </li> <li> <a href="https://redis.io/docs/develop/interact/search-and-query/query/range/"> Numeric range </a> </li> <li> <a href="https://redis.io/docs/develop/interact/search-and-query/query/full-text/"> Full-text </a> </li> <li> <a href="https://redis.io/docs/develop/interact/search-and-query/query/geo-spatial/"> Geospatial </a> </li> </ul> <p> You can also <a href="https://redis.io/docs/develop/interact/search-and-query/query/combined/"> combine multiple queries </a> as a filter. </p> <p> <strong> Syntax </strong> </p> <p> Vector search queries with filters follow this basic structure: </p> <pre tabindex="0"><code>FT.SEARCH &lt;index_name&gt; &lt;primary_filter_query&gt;=&gt;[...] </code></pre> <p> where <code> &lt;primary_filter_query&gt; </code> defines document selection and filtering. </p> <p> <strong> Example </strong> </p> <pre tabindex="0"><code>FT.SEARCH documents "(@title:Sports @year:[2020 2022])=&gt;[KNN 10 @doc_embedding $BLOB]" PARAMS 2 BLOB "\x12\xa9\xf5\x6c" DIALECT 4 </code></pre> <h3 id="how-filtering-works"> How filtering works </h3> <p> Redis uses internal algorithms to optimize the filtering computation for vector search. The runtime algorithm is determined by heuristics that aim to minimize query latency based on several factors derived from the query and the index. </p> <p> <strong> Batches mode </strong> </p> <p> Batches mode works by paginating through small batches of nearest neighbors from the index: </p> <ul> <li> A batch of high-scoring documents from the vector index is retrieved. These documents are yielded only if the <code> &lt;primary_filter_query&gt; </code> is satisfied. In other words, the document must contain a similar vector and meet the filter criteria. </li> <li> The iterative procedure terminates when <code> &lt;top_k&gt; </code> documents that pass the filter criteria are yielded, or after every vector in the index has been processed. </li> <li> The batch size is determined automatically by heuristics based on <code> &lt;top_k&gt; </code> and the ratio between the expected number of documents in the index that pass the <code> &lt;primary_filter_query&gt; </code> and the vector index size. </li> <li> The goal is to minimize the total number of batches required to get the <code> &lt;top_k&gt; </code> results while preserving the smallest batch size possible. Note that the batch size may change dynamically in each iteration based on the number of results that pass the filter in previous batches. </li> </ul> <p> <strong> Ad-hoc brute force mode </strong> </p> <ul> <li> The score of every vector corresponding to a document that passes the filter is computed, and the <code> &lt;top_k&gt; </code> results are selected and returned. </li> <li> This approach is preferable when the number of documents passing the <code> &lt;primary_filter_query&gt; </code> is relatively small. </li> <li> The results of the KNN query will always be accurate in this mode, even if the underlying vector index algorithm is an approximate one. </li> </ul> <p> The execution mode may switch from batch mode to ad-hoc brute-force mode during the run, based on updated estimations of relevant factors from one batch to another. </p> <h2 id="runtime-query-parameters"> Runtime query parameters </h2> <h3 id="filter-mode"> Filter mode </h3> <p> By default, Redis selects the best filter mode to optimize query execution. You can override the auto-selected policy using these optional parameters: </p> <table> <thead> <tr> <th style="text-align:left"> Parameter </th> <th style="text-align:left"> Description </th> <th style="text-align:left"> Options </th> </tr> </thead> <tbody> <tr> <td style="text-align:left"> <code> HYBRID_POLICY </code> </td> <td style="text-align:left"> Specifies the filter mode to use during vector search with filters (hybrid). </td> <td style="text-align:left"> <code> BATCHES </code> or <code> ADHOC_BF </code> </td> </tr> <tr> <td style="text-align:left"> <code> BATCH_SIZE </code> </td> <td style="text-align:left"> A fixed batch size to use in every iteration when the <code> BATCHES </code> policy is auto-selected or requested. </td> <td style="text-align:left"> Positive integer. </td> </tr> </tbody> </table> <h3 id="index-specific-query-parameters"> Index-specific query parameters </h3> <p> <strong> FLAT </strong> </p> <p> Currently, there are no runtime parameters available for FLAT indexes. </p> <p> <strong> HNSW </strong> </p> <p> Optional runtime parameters for HNSW indexes are: </p> <table> <thead> <tr> <th style="text-align:left"> Parameter </th> <th style="text-align:left"> Description </th> <th style="text-align:left"> Default value </th> </tr> </thead> <tbody> <tr> <td style="text-align:left"> <code> EF_RUNTIME </code> </td> <td style="text-align:left"> The maximum number of top candidates to hold during the KNN search. Higher values lead to more accurate results at the expense of a longer query runtime. </td> <td style="text-align:left"> The value passed during index creation. The default is 10. </td> </tr> <tr> <td style="text-align:left"> <code> EPSILON </code> </td> <td style="text-align:left"> The relative factor that sets the boundaries for a vector range query. Vector candidates whose distance from the query vector is <code> radius * (1 + EPSILON) </code> are potentially scanned, allowing a more extensive search and more accurate results at the expense of runtime. </td> <td style="text-align:left"> The value passed during index creation. The default is 0.01. </td> </tr> </tbody> </table> <h3 id="important-notes"> Important notes </h3> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Important notes: </div> <ol> <li> <p> When performing a KNN vector search, you specify <code> &lt;top_k&gt; </code> nearest neighbors. However, the default Redis query <code> LIMIT </code> parameter (used for pagination) is 10. In order to get <code> &lt;top_k&gt; </code> returned results, you must also specify <code> LIMIT 0 &lt;top_k&gt; </code> in your search command. See examples below. </p> </li> <li> <p> By default, the results are sorted by their document's score. To sort by vector similarity score, use <code> SORTBY &lt;distance_field&gt; </code> . See examples below. </p> </li> <li> <p> Depending on your chosen distance metric, the calculated distance between vectors in an index have different bounds. For example, <code> Cosine </code> distance is bounded by <code> 2 </code> , while <code> L2 </code> distance is not bounded. When performing a vector range query, the best practice is to adjust the <code> &lt;radius&gt; </code> parameter based on your use case and required recall or precision metrics. </p> </li> </ol> </div> </div> <h2 id="vector-search-examples"> Vector search examples </h2> <p> Below are a number of examples to help you get started. For more comprehensive walkthroughs, see the <a href="/docs/latest/develop/get-started/vector-database"> Redis vector quickstart guide </a> and the <a href="https://github.com/redis-developer/redis-ai-resources"> Redis AI Resources </a> Github repo. </p> <h3 id="knn-vector-search-examples"> KNN vector search examples </h3> <p> Return the 10 nearest neighbor documents for which the <code> doc_embedding </code> vector field is the closest to the query vector represented by the following 4-byte blob: </p> <pre tabindex="0"><code>FT.SEARCH documents "*=&gt;[KNN 10 @doc_embedding $BLOB]" PARAMS 2 BLOB "\x12\xa9\xf5\x6c" SORTBY __vector_score DIALECT 4 </code></pre> <p> Return the top 10 nearest neighbors and customize the <code> K </code> and <code> EF_RUNTIME </code> parameters using query parameters. See the "Optional arguments" section in <a href="/docs/latest/commands/ft.search"> FT.SEARCH command </a> . Set the <code> EF_RUNTIME </code> value to 150, assuming <code> doc_embedding </code> is an <code> HNSW </code> index: </p> <pre tabindex="0"><code>FT.SEARCH documents "*=&gt;[KNN $K @doc_embedding $BLOB EF_RUNTIME $EF]" PARAMS 6 BLOB "\x12\xa9\xf5\x6c" K 10 EF 150 DIALECT 4 </code></pre> <p> Assign a custom name to the distance field ( <code> vector_distance </code> ) and then sort using that name: </p> <pre tabindex="0"><code>FT.SEARCH documents "*=&gt;[KNN 10 @doc_embedding $BLOB AS vector_distance]" PARAMS 2 BLOB "\x12\xa9\xf5\x6c" SORTBY vector_distance DIALECT 4 </code></pre> <p> Use <a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/query_syntax#query-attributes"> query attributes </a> syntax to specify optional parameters and the distance field name: </p> <pre tabindex="0"><code>FT.SEARCH documents "*=&gt;[KNN 10 @doc_embedding $BLOB]=&gt;{$EF_RUNTIME: $EF; $YIELD_DISTANCE_AS: vector_distance}" PARAMS 4 EF 150 BLOB "\x12\xa9\xf5\x6c" SORTBY vector_distance DIALECT 4 </code></pre> <p> To explore additional Python vector search examples, review recipes for the <a href="https://github.com/redis-developer/redis-ai-resources/blob/main/python-recipes/vector-search/00_redispy.ipynb"> <code> Redis Python </code> </a> client library and the <a href="https://github.com/redis-developer/redis-ai-resources/blob/main/python-recipes/vector-search/01_redisvl.ipynb"> <code> Redis Vector Library </code> </a> . </p> <h3 id="filter-examples"> Filter examples </h3> <p> For these examples, assume you created an index named <code> movies </code> with records of different movies and their metadata. </p> <p> Among the movies that have <code> 'Dune' </code> in the <code> title </code> field and <code> year </code> between <code> [2020, 2022] </code> , return the top 10 nearest neighbors, sorted by <code> movie_distance </code> : </p> <pre tabindex="0"><code>FT.SEARCH movies "(@title:Dune @year:[2020 2022])=&gt;[KNN 10 @movie_embedding $BLOB AS movie_distance]" PARAMS 2 BLOB "\x12\xa9\xf5\x6c" SORTBY movie_distance DIALECT 4 </code></pre> <p> Among the movies that have <code> action </code> as a category tag, but not <code> drama </code> , return the top 10 nearest neighbors, sorted by <code> movie_distance </code> : </p> <pre tabindex="0"><code>FT.SEARCH movies "(@category:{action} ~@category:{drama})=&gt;[KNN 10 @doc_embedding $BLOB AS movie_distance]" PARAMS 2 BLOB "\x12\xa9\xf5\x6c" SORTBY movie_distance DIALECT 4 </code></pre> <p> Among the movies that have <code> drama </code> or <code> action </code> as a category tag, return the top 10 nearest neighbors and explicitly set the filter mode (hybrid policy) to "ad-hoc brute force" rather than it being auto-selected: </p> <pre tabindex="0"><code>FT.SEARCH movies "(@category:{drama | action})=&gt;[KNN 10 @doc_embedding $BLOB HYBRID_POLICY ADHOC_BF]" PARAMS 2 BLOB "\x12\xa9\xf5\x6c" SORTBY __vec_score DIALECT 4 </code></pre> <p> Among the movies that have <code> action </code> as a category tag, return the top 10 nearest neighbors and explicitly set the filter mode (hybrid policy) to "batches" and batch size 50 using a query parameter: </p> <pre tabindex="0"><code>FT.SEARCH movies "(@category:{action})=&gt;[KNN 10 @doc_embedding $BLOB HYBRID_POLICY BATCHES BATCH_SIZE $BATCH_SIZE]" PARAMS 4 BLOB "\x12\xa9\xf5\x6c" BATCH_SIZE 50 DIALECT 4 </code></pre> <p> Run the same query as above and use the query attributes syntax to specify optional parameters: </p> <pre tabindex="0"><code>FT.SEARCH movies "(@category:{action})=&gt;[KNN 10 @doc_embedding $BLOB]=&gt;{$HYBRID_POLICY: BATCHES; $BATCH_SIZE: 50}" PARAMS 2 BLOB "\x12\xa9\xf5\x6c" DIALECT 4 </code></pre> <p> To explore additional Python vector search examples, review recipes for the <a href="https://github.com/redis-developer/redis-ai-resources/blob/main/python-recipes/vector-search/00_redispy.ipynb"> <code> Redis Python </code> </a> client library and the <a href="https://github.com/redis-developer/redis-ai-resources/blob/main/python-recipes/vector-search/01_redisvl.ipynb"> <code> Redis Vector Library </code> </a> . </p> <h3 id="range-query-examples"> Range query examples </h3> <p> For these examples, assume you created an index named <code> products </code> with records of different products and metadata from an ecommerce site. </p> <p> Return 100 products for which the distance between the <code> description_vector </code> field and the specified query vector blob is at most 5: </p> <pre tabindex="0"><code>FT.SEARCH products "@description_vector:[VECTOR_RANGE 5 $BLOB]" PARAMS 2 BLOB "\x12\xa9\xf5\x6c" LIMIT 0 100 DIALECT 4 </code></pre> <p> Run the same query as above and set the <code> EPSILON </code> parameter to <code> 0.5 </code> , assuming <code> description_vector </code> is HNSW index, yield the vector distance between <code> description_vector </code> and the query result in a field named <code> vector_distance </code> , and sort the results by that distance. </p> <pre tabindex="0"><code>FT.SEARCH products "@description_vector:[VECTOR_RANGE 5 $BLOB]=&gt;{$EPSILON:0.5; $YIELD_DISTANCE_AS: vector_distance}" PARAMS 2 BLOB "\x12\xa9\xf5\x6c" SORTBY vector_distance LIMIT 0 100 DIALECT 4 </code></pre> <p> Use the vector range query as a filter: return all the documents that contain either <code> 'shirt' </code> in their <code> type </code> tag with their <code> year </code> value in the range <code> [2020, 2022] </code> or a vector stored in <code> description_vector </code> whose distance from the query vector is no more than <code> 0.8 </code> , then sort the results by their vector distance, if it is in the range: </p> <pre tabindex="0"><code>FT.SEARCH products "(@type:{shirt} @year:[2020 2022]) | @description_vector:[VECTOR_RANGE 0.8 $BLOB]=&gt;{$YIELD_DISTANCE_AS: vector_distance}" PARAMS 2 BLOB "\x12\xa9\xf5\x6c" SORTBY vector_distance DIALECT 4 </code></pre> <p> To explore additional Python vector search examples, review recipes for the <a href="https://github.com/redis-developer/redis-ai-resources/blob/main/python-recipes/vector-search/00_redispy.ipynb"> <code> Redis Python </code> </a> client library and the <a href="https://github.com/redis-developer/redis-ai-resources/blob/main/python-recipes/vector-search/01_redisvl.ipynb"> <code> Redis Vector Library </code> </a> . </p> <h2 id="next-steps"> Next steps </h2> <p> Vector embeddings and vector search are not new concepts. Many of the largest companies have used vectors to represent products in ecommerce catalogs or content in advertising pipelines for well over a decade. </p> <p> With the emergence of Large Language Models (LLMs) and the proliferation of applications that require advanced information retrieval techniques, Redis is well positioned to serve as your high performance query engine for semantic search and more. </p> <p> Here are some additonal resources that apply vector search for different use cases: </p> <ul> <li> <a href="https://github.com/redis-developer/redis-ai-resources/blob/main/python-recipes/RAG/01_redisvl.ipynb"> Retrieval augmented generation from scratch </a> </li> <li> <a href="https://github.com/redis-developer/redis-ai-resources/blob/main/python-recipes/semantic-cache/semantic_caching_gemini.ipynb"> Semantic caching </a> </li> </ul> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/develop/interact/search-and-query/advanced-concepts/vectors/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/7.4/databases/durability-ha/discovery-service/.html
<section class="prose w-full py-12 max-w-none"> <h1> Discovery service </h1> <p> The Discovery Service provides an IP-based connection management service used when connecting to Redis Enterprise Software databases. When used in conjunction with Redis Enterprise Software's other high availability features, the Discovery Service assists an application scope with topology changes such as adding, removing of nodes, node failovers and so on. It does this by providing your application with the ability to easily discover which node hosts the database endpoint. The API used for discovery service is compliant with the Redis Sentinel API. </p> <p> Discovery Service is an alternative for applications that do not want to depend on DNS name resolution for their connectivity. Discovery Service and DNS based connectivity are not mutually exclusive. They can be used side by side in a given cluster where some clients can use Discovery Service based connection while others can use DNS name resolution when connecting to databases. </p> <h2 id="how-discovery-service-works"> How discovery service works </h2> <p> The Discovery Service is available for querying on each node of the cluster, listening on port 8001. To employ it, your application utilizes a <a href="/docs/latest/operate/rs/7.4/databases/connect/supported-clients-browsers/"> Redis Sentinel enabled client library </a> to connect to the Discovery Service and request the endpoint for the given database. The Discovery Service replies with the database's endpoint for that database. In case of a node failure, the Discovery Service is updated by the cluster manager with the new endpoint and clients unable to connect to the database endpoint due to the failover, can re-query the discovery service for the new endpoint for the database. </p> <p> The Discovery Service can return either the internal or external endpoint for a database. If you query the discovery service for the endpoint of a database named "db1", the Discovery Service returns the external endpoint information by default. If only an internal endpoint exists with no external endpoint the default behavior is to return the internal endpoint. The "@internal" is added to the end of the database name to explicitly ask for the internal endpoint. to query the internal endpoint explicitly with database name "db1", you can pass in the database name as "db1@internal". </p> <p> If you'd like to examine the metadata returned from Redis Enterprise Software Discovery Service you can connect to port 8001 with redis-cli utility and execute "SENTINEL masters". Following is a sample output from one of the nodes of a Redis Enterprise Software cluster: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ ./redis-cli -p <span class="m">8001</span> </span></span><span class="line"><span class="cl">127.0.0.1:8001&gt; SENTINEL masters </span></span><span class="line"><span class="cl">1<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"name"</span> </span></span><span class="line"><span class="cl">2<span class="o">)</span> <span class="s2">"db1@internal"</span> </span></span><span class="line"><span class="cl">3<span class="o">)</span> <span class="s2">"ip"</span> </span></span><span class="line"><span class="cl">4<span class="o">)</span> <span class="s2">"10.0.0.45"</span> </span></span><span class="line"><span class="cl">5<span class="o">)</span> <span class="s2">"port"</span> </span></span><span class="line"><span class="cl">6<span class="o">)</span> <span class="s2">"12000"</span> </span></span><span class="line"><span class="cl">7<span class="o">)</span> <span class="s2">"flags"</span> </span></span><span class="line"><span class="cl">8<span class="o">)</span> <span class="s2">"master,disconnected"</span> </span></span><span class="line"><span class="cl">9<span class="o">)</span> <span class="s2">"num-other-sentinels"</span> </span></span><span class="line"><span class="cl">10<span class="o">)</span> <span class="s2">"0"</span> </span></span><span class="line"><span class="cl">2<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"name"</span> </span></span><span class="line"><span class="cl">2<span class="o">)</span> <span class="s2">"db1"</span> </span></span><span class="line"><span class="cl">3<span class="o">)</span> <span class="s2">"ip"</span> </span></span><span class="line"><span class="cl">4<span class="o">)</span> <span class="s2">"10.0.0.45"</span> </span></span><span class="line"><span class="cl">5<span class="o">)</span> <span class="s2">"port"</span> </span></span><span class="line"><span class="cl">6<span class="o">)</span> <span class="s2">"12000"</span> </span></span><span class="line"><span class="cl">7<span class="o">)</span> <span class="s2">"flags"</span> </span></span><span class="line"><span class="cl">8<span class="o">)</span> <span class="s2">"master,disconnected"</span> </span></span><span class="line"><span class="cl">9<span class="o">)</span> <span class="s2">"num-other-sentinels"</span> </span></span><span class="line"><span class="cl">10<span class="o">)</span> <span class="s2">"0"</span> </span></span></code></pre> </div> <p> It is important to note that, the Discovery Service is not a full implementation of the <a href="/docs/latest/operate/oss_and_stack/management/sentinel/"> Redis Sentinel protocol </a> . There are aspects of the protocol that are not applicable or would be duplication with existing technology in Redis Enterprise Software. The Discovery Service implements only the parts required to provide applications with easy High Availability, be compatible with the protocol, and not rely on DNS to derive which node in the cluster to communicate with. </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> To use Redis Sentinel, every database name must be unique across the cluster. </div> </div> <h2 id="redis-client-support"> Redis client support </h2> <p> We recommend these clients that are tested for use with the <a href="/docs/latest/operate/rs/7.4/databases/durability-ha/discovery-service/"> Discovery Service </a> that uses the Redis Sentinel API: </p> <ul> <li> <a href="https://github.com/andymccurdy/redis-py"> Redis-py </a> (Python redis client) </li> <li> <a href="https://github.com/redis/hiredis"> HiRedis </a> (C redis client) </li> <li> <a href="https://github.com/xetorthio/jedis"> Jedis </a> (Java redis client) </li> <li> <a href="https://github.com/luin/ioredis"> Ioredis </a> (NodeJS redis client) </li> </ul> <p> If you need to use another client, consider using <a href="https://github.com/RedisLabs/sentinel_tunnel"> Sentinel Tunnel </a> to discover the current Redis master with Sentinel and create a TCP tunnel between a local port on the client and the master. </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> Redis Sentinel API can return endpoints for both master and replica endpoints. Discovery Service only supports master endpoints and does not support returning replica endpoints for a database. </div> </div> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/databases/durability-ha/discovery-service/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/.html
<section class="prose w-full py-12"> <h1> Commands </h1> </section>
https://redis.io/docs/latest/operate/kubernetes/re-databases/db-controller/.html
<section class="prose w-full py-12 max-w-none"> <h1> Manage Redis Enterprise databases for Kubernetes </h1> <p class="text-lg -mt-5 mb-10"> This section describes how the database controller provides the ability to create, manage, and use databases via a database custom resource. </p> <h2 id="redis-enterprise-database-redb-lifecycle"> Redis Enterprise database (REDB) lifecycle </h2> <p> A Redis Enterprise database (REDB) is created with a custom resource file. The custom resource defines the size, name, and other specifications for the REDB. The database is created when you apply the custom resource file. </p> <p> The database controller in Redis Enterprise for Kubernetes: </p> <ul> <li> Discovers the custom resource </li> <li> Makes sure the REDB is created in the same namespace as the Redis Enterprise cluster (REC) </li> <li> Maintains consistency between the custom resource and the REDB </li> </ul> <p> The database controller recognizes the new custom resource and validates the specification. If valid, the controller combines the values specified in the custom resource with default values to create a full specification. It then uses this full specification to create the database on the specified Redis Enterprise cluster (REC). </p> <p> Once the database is created, it is exposed with the same service mechanisms by the service rigger for the Redis Enterprise cluster. If the database <a href="/docs/latest/operate/kubernetes/delete-custom-resources/"> custom resource is deleted </a> , the database and its services are deleted from the cluster. </p> <h3 id="flexible-deployment-options"> Flexible deployment options </h3> <p> Databases in multiple namespaces can be managed by the same operator. To learn more, see <a href="/docs/latest/operate/kubernetes/re-clusters/multi-namespace/"> Manage databases in multiple namespaces </a> . </p> <p> To learn more about designing a multi-namespace Redis Enterprise cluster, see <a href="/docs/latest/operate/kubernetes/architecture/deployment-options/"> flexible deployment options </a> . </p> <h2 id="create-a-database"> Create a database </h2> <p> Your Redis Enterprise database custom resource must be of the <code> kind: RedisEnterpriseDatabase </code> and have values for <code> name </code> and <code> memorySize </code> . All other values are optional and will be defaults if not specified. </p> <ol> <li> <p> Create a file (in this example mydb.yaml) that contains your database custom resource. </p> <div class="highlight"> <pre class="chroma"><code class="language-YAML" data-lang="YAML"><span class="line"><span class="cl"><span class="nt">apiVersion</span><span class="p">:</span><span class="w"> </span><span class="l">app.redislabs.com/v1alpha1</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">kind</span><span class="p">:</span><span class="w"> </span><span class="l">RedisEnterpriseDatabase</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">metadata</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">mydb</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">spec</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">memorySize</span><span class="p">:</span><span class="w"> </span><span class="l">1GB</span><span class="w"> </span></span></span></code></pre> </div> <p> To create a REDB in a different namespace from your REC, you need to specify the cluster with <code> redisEnterpriseCluster </code> in the <code> spec </code> section of your RedisEnterpriseDatabase custom resource. </p> <div class="highlight"> <pre class="chroma"><code class="language-YAML" data-lang="YAML"><span class="line"><span class="cl"><span class="nt">redisEnterpriseCluster</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">rec</span><span class="w"> </span></span></span></code></pre> </div> </li> <li> <p> Apply the file in the namespace you want your database to be in. </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">kubectl apply -f mydb.yaml </span></span></code></pre> </div> </li> <li> <p> Check the status of your database. </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">kubectl get redb mydb -o <span class="nv">jsonpath</span><span class="o">=</span><span class="s2">"{.status.status}"</span> </span></span></code></pre> </div> <p> When the status is <code> active </code> , the database is ready to use. </p> </li> </ol> <h2 id="modify-a-database"> Modify a database </h2> <p> The custom resource defines the properties of the database. To change the database, you can edit your original specification and apply the change or use <code> kubectl edit </code> . </p> <p> To modify the database: </p> <ol> <li> <p> Edit the definition: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">kubectl edit redb mydb </span></span></code></pre> </div> </li> <li> <p> Change the specification (only properties in <code> spec </code> section) and save the changes. <br/> For more details, see <a href="https://github.com/RedisLabs/redis-enterprise-k8s-docs/blob/master/redis_enterprise_database_api.md#redisenterprisedatabasespec"> RedisEnterpriseDatabaseSpec </a> or <a href="/docs/latest/operate/kubernetes/reference/redis_enterprise_database_api/"> Options for Redis Enterprise databases </a> . </p> </li> <li> <p> Monitor the status to see when the changes take effect: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">kubectl get redb mydb -o <span class="nv">jsonpath</span><span class="o">=</span><span class="s2">"{.status.status}"</span> </span></span></code></pre> </div> <p> When the status is <code> active </code> , the database is ready for use. </p> </li> </ol> <h2 id="delete-a-database"> Delete a database </h2> <p> The database exists as long as the custom resource exists. If you delete the custom resource, the database controller deletes the database. The database controller removes the database and its services from the cluster. </p> <p> To delete a database, run: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">kubectl delete redb mydb </span></span></code></pre> </div> <h2 id="connect-to-a-database"> Connect to a database </h2> <p> After the database controller creates a database, the services for accessing the database are created in the same namespace. By default there are two services, one 'ClusterIP' service and one 'headless' service. <br/> Connection information for the database is stored in a Kubernetes <a href="https://kubernetes.io/docs/concepts/configuration/secret/"> secret </a> maintained by the database controller. This secret contains: </p> <ul> <li> The database port ( <code> port </code> ) </li> <li> A comma separated list of service names ( <code> service_names </code> ) </li> <li> The database password for authenticating ( <code> password </code> ) </li> </ul> <p> The name of that secret is stored in the database custom resource. </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> Use these steps to connect to your database from within your K8s cluster. To access your database from outside the K8s cluster, set up the <a href="/docs/latest/operate/kubernetes/networking/ingress/"> Ingress </a> controller or use OpenShift routes. </div> </div> <ol> <li> <p> Retrieve the secret name. </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">kubectl get redb mydb -o <span class="nv">jsonpath</span><span class="o">=</span><span class="s2">"{.spec.databaseSecretName}"</span> </span></span></code></pre> </div> <p> The database secret name usually takes the form of <code> redb-&lt;database_name&gt; </code> , so in our example it will be <code> redb-mydb </code> . </p> </li> <li> <p> Retrieve and decode the password. </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">kubectl get secret redb-mydb -o <span class="nv">jsonpath</span><span class="o">=</span><span class="s2">"{.data.password}"</span> <span class="p">|</span> base64 --decode </span></span></code></pre> </div> </li> <li> <p> Retrieve and decode the port number. </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">kubectl get secret redb-mydb -o <span class="nv">jsonpath</span><span class="o">=</span><span class="s2">"{.data.port}"</span> <span class="p">|</span> base64 --decode </span></span></code></pre> </div> </li> <li> <p> Retrieve and decode the service_names. </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">kubectl get secret redb-mydb -o <span class="nv">jsonpath</span><span class="o">=</span><span class="s2">"{.data.service_names}"</span> <span class="p">|</span> base64 --decode </span></span></code></pre> </div> <p> You'll need to pick just one service listed here to use for connecting. </p> </li> <li> <p> From a pod within your cluster, use <code> redis-cli </code> to connect to your database. </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">redis-cli -h &lt;service_name&gt; -p &lt;port&gt; </span></span></code></pre> </div> </li> <li> <p> Enter the password you retrieved from the secret. </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">auth &lt;password&gt; </span></span></code></pre> </div> <p> You are now connected to your database! </p> </li> </ol> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/kubernetes/re-databases/db-controller/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rc/security/aws-transit-gateway/.html
<section class="prose w-full py-12 max-w-none"> <h1> Connect to Amazon Web Services Transit Gateway </h1> <p> <a href="https://docs.aws.amazon.com/vpc/latest/tgw/how-transit-gateways-work.html"> Amazon Web Services (AWS) Transit Gateway </a> acts as a Regional virtual router for traffic flowing between your virtual private cloud(s) (VPCs) and on-premises networks. You can attach different resources to your Transit Gateway which include: </p> <ul> <li> One or more VPCs </li> <li> One or more virtual private network (VPN) connections </li> <li> One or more AWS Direct Connect gateways </li> <li> One or more Transit Gateway Connect attachments </li> <li> One or more transit gateway peering connections </li> </ul> <p> You can connect your Redis Cloud Pro subscription to a Transit Gateway which is attached to the VPC of your application. This lets your application connect securely to your Redis Cloud database while optimizing performance. </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> Transit Gateway is available only with Redis Cloud Pro. It is not supported for Redis Cloud Essentials. </div> </div> <h2 id="considerations"> Considerations </h2> <p> You can use Transit Gateway as an alternative to <a href="/docs/latest/operate/rc/security/vpc-peering/"> VPC peering </a> , or you can enable both for your subscription. </p> <p> Compared to VPC peering, Transit Gateway: </p> <ul> <li> <p> Supports complex network topologies, such as multiple VPCs or site-to-site VPNs. </p> </li> <li> <p> Uses security groups and network ACLs to control traffic between VPCs. </p> </li> <li> <p> Has a higher network latency and cost than VPC peering due to Transit Gateway infrastructure costs. </p> </li> </ul> <p> Consider using VPC peering and Transit Gateway in parallel for the following situations: </p> <ul> <li> <p> When migrating from one connectivity solution to the other. </p> </li> <li> <p> If different applications need to connect to the same database but have different latency or security requirements. </p> </li> </ul> <h2 id="prerequisites"> Prerequisites </h2> <p> Before you can set up Transit Gateway: </p> <ol> <li> <p> <a href="/docs/latest/operate/rc/databases/create-database/create-pro-database-new/"> Create a database with Redis Cloud Pro </a> from the <a href="https://cloud.redis.io/#/"> Redis Cloud console </a> . </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/vpc/latest/tgw/tgw-transit-gateways.html#create-tgw"> Create a transit gateway </a> from the <a href="https://console.aws.amazon.com/vpc/"> AWS VPC console </a> . </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/vpc/latest/tgw/tgw-transit-gateways.html#tgw-sharing"> Share the transit gateway </a> from the <a href="https://console.aws.amazon.com/ram/"> AWS resource access manager </a> . </p> </li> </ol> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> If you have a self-managed AWS account, you will need to set its IAM Instance Policy to include Transit Gateway. See <a href="/docs/latest/operate/rc/cloud-integrations/aws-cloud-accounts/iam-resources/aws-console/"> Create IAM resources using the AWS console </a> (deprecated) for more information. </div> </div> <h2 id="aws-transit-gateway"> AWS Transit Gateway </h2> <p> To set up Transit Gateway: </p> <ol> <li> <p> <a href="#associate-resource-share"> Associate your resource share with the Redis AWS account </a> . </p> </li> <li> <p> <a href="#accept-resource-share"> Accept the resource share and create an attachment </a> . </p> </li> <li> <p> <a href="#add-consumer-cidrs"> Add consumer CIDRs </a> to the attachment. </p> </li> <li> <p> <a href="#update-route-tables"> Update AWS route tables </a> with the Redis Cloud producer CIDRs. </p> </li> </ol> <h3 id="associate-resource-share"> Associate resource share with Redis Cloud </h3> <p> In this step, you will associate your resource share with your subscription's AWS account. You can do this either in the <a href="#aws-console"> AWS console </a> or with the <a href="#aws-cli"> AWS CLI </a> . </p> <h4 id="aws-console"> AWS Console </h4> <p> To use the AWS console to set up the resource share: </p> <ol> <li> <p> From the <a href="https://cloud.redis.io/"> Redis Cloud console </a> , select the <strong> Subscriptions </strong> menu and then select your subscription from the list. </p> </li> <li> <p> Select <strong> Connectivity &gt; Transit Gateway </strong> to view the transit gateway settings. </p> </li> <li> <p> In the <strong> Share Transit Gateway </strong> section, select <strong> Copy </strong> under <strong> AWS console </strong> to copy the Redis AWS Account number. </p> <a href="/docs/latest/images/rc/tgw-share-transit-gateway.png" sdata-lightbox="/images/rc/tgw-share-transit-gateway.png"> <img alt="The Share Transit Gateway section." src="/docs/latest/images/rc/tgw-share-transit-gateway.png" width="80%"/> </a> </li> <li> <p> Follow the guide to <a href="https://docs.aws.amazon.com/ram/latest/userguide/working-with-sharing-update.html"> Update a resource share </a> in the <a href="https://console.aws.amazon.com/ram/"> AWS resource access manager </a> . </p> <p> During the <strong> Grant access to principals </strong> step, select <strong> AWS Account </strong> in the <strong> Select principal type </strong> field. Enter the copied AWS account number in the <strong> Enter an AWS Account ID </strong> field. </p> <a href="/docs/latest/images/rc/aws-tgw-add-principal.png" sdata-lightbox="/images/rc/aws-tgw-add-principal.png"> <img alt="The AWS Add principal field." src="/docs/latest/images/rc/aws-tgw-add-principal.png" width="80%"/> </a> <p> After the principal is added, it may take some time before it is associated. You can see the status of the principals under <strong> Shared Principals </strong> in the resource share page. </p> </li> </ol> <h4 id="aws-cli"> AWS CLI </h4> <p> To use the AWS CLI to set up the resource share: </p> <ol> <li> <p> From the <a href="https://cloud.redis.io/"> Redis Cloud console </a> , select the <strong> Subscriptions </strong> menu and then select your subscription from the list. </p> </li> <li> <p> Select <strong> Connectivity &gt; Transit Gateway </strong> to view the transit gateway settings. </p> </li> <li> <p> In the <strong> Share Transit Gateway </strong> section, select <strong> Copy </strong> under <strong> AWS CLI Command </strong> to copy the Redis AWS Account number. </p> <a href="/docs/latest/images/rc/tgw-share-transit-gateway.png" sdata-lightbox="/images/rc/tgw-share-transit-gateway.png"> <img alt="The Share Transit Gateway section." src="/docs/latest/images/rc/tgw-share-transit-gateway.png" width="80%"/> </a> </li> <li> <p> Enter the copied CLI command into a terminal shell. Replace <code> &lt;TGW ARN&gt; </code> with the Amazon resource name of your transit gateway. </p> </li> </ol> <h3 id="accept-resource-share"> Accept resource share and create attachment </h3> <p> After you've associated the Redis AWS account with your resource share, you must accept the resource share in the Redis Cloud console. </p> <ol> <li> <p> In your Redis Cloud subscription's Transit Gateway settings, you should now see that a <strong> Resource Share </strong> is available. Select <strong> Resource Shares </strong> to view the resource share you initiated. </p> <a href="/docs/latest/images/rc/tgw-resource-shares-button.png" sdata-lightbox="/images/rc/tgw-resource-shares-button.png"> <img alt="The Share Transit Gateway section." src="/docs/latest/images/rc/tgw-resource-shares-button.png" width="250px"/> </a> </li> <li> <p> Select <strong> Accept </strong> to associate the <strong> Resource Share </strong> with your Redis Cloud console account. </p> <a href="/docs/latest/images/rc/tgw-accept-resource-shares.png" sdata-lightbox="/images/rc/tgw-accept-resource-shares.png"> <img alt="The Accept resource shares section." src="/docs/latest/images/rc/tgw-accept-resource-shares.png" width="80%"/> </a> </li> <li> <p> Select <strong> Close </strong> to close the <strong> Accept resource shares </strong> section. </p> </li> <li> <p> You will now see your transit gateway in the <strong> Transit Gateways </strong> section. After the <strong> TGW status </strong> is <strong> Available </strong> , select <strong> Create Attachment </strong> under <strong> Attachment status </strong> . </p> <a href="/docs/latest/images/rc/tgw-create-attachment-button.png" sdata-lightbox="/images/rc/tgw-create-attachment-button.png"> <img alt="The Create attachment button." src="/docs/latest/images/rc/tgw-create-attachment-button.png" width="250px"/> </a> <p> This will request a peering attachment representing Redis's AWS account to the Transit Gateway. </p> </li> <li> <p> If your transit gateway does not automatically accept peering attachment requests, the attachment will be in <strong> Pending acceptance </strong> status. Follow the guide to <a href="https://docs.aws.amazon.com/vpc/latest/tgw/tgw-peering.html#tgw-peering-accept-reject"> Accept a peering attachment request </a> from the <a href="https://console.aws.amazon.com/vpc/"> AWS VPC console </a> . </p> </li> </ol> <h3 id="add-consumer-cidrs"> Add consumer CIDRs </h3> <ol> <li> <p> In your Redis Cloud subscription's Transit Gateway settings, in the <strong> Transit Gateways </strong> section, select <strong> Add CIDRs </strong> under <strong> Consumer CIDRs </strong> . </p> <a href="/docs/latest/images/rc/tgw-add-cidrs-button.png" sdata-lightbox="/images/rc/tgw-add-cidrs-button.png"> <img alt="The Add CIDRs button." src="/docs/latest/images/rc/tgw-add-cidrs-button.png" width="150px"/> </a> </li> <li> <p> Enter the IPv4 CIDR of the VPC you want to connect to that is also connected to your transit gateway. To find this, go to the <a href="https://console.aws.amazon.com/vpc/"> AWS VPC console </a> and select <strong> Your VPCs </strong> . </p> <p> Select <strong> Add </strong> to add another CIDR if needed. </p> <a href="/docs/latest/images/rc/tgw-add-additional-cidrs-button.png" sdata-lightbox="/images/rc/tgw-add-additional-cidrs-button.png"> <img alt="The Add button for adding additional CIDRs." src="/docs/latest/images/rc/tgw-add-additional-cidrs-button.png" width="150px"/> </a> <p> Select <strong> Save </strong> to save your changes. </p> </li> </ol> <h3 id="update-route-tables"> Update AWS route tables </h3> <p> To finish Transit gateway setup, <a href="https://docs.aws.amazon.com/vpc/latest/peering/vpc-peering-routing.html"> update your route tables for the peering connection </a> with the following details: </p> <ol> <li> <p> In the <strong> Destination </strong> field, enter the producer deployment CIDRs. </p> <p> You can find the producer deployment CIDRs on the Redis Cloud console in the Transit Gateway settings by selecting <strong> More actions &gt; View Attachment </strong> in the <strong> Transit Gateway </strong> section. </p> <a href="/docs/latest/images/rc/tgw-attachment-more-actions-menu.png" sdata-lightbox="/images/rc/tgw-attachment-more-actions-menu.png"> <img alt="The More actions menu." src="/docs/latest/images/rc/tgw-attachment-more-actions-menu.png" width="300px"/> </a> <a href="/docs/latest/images/rc/tgw-producer-cidr-copy.png" sdata-lightbox="/images/rc/tgw-producer-cidr-copy.png"> <img alt="The Producer deployment CIDRs in the Attachment settings. " src="/docs/latest/images/rc/tgw-producer-cidr-copy.png" width="100%"/> </a> </li> <li> <p> In the <strong> Target </strong> field, select <strong> Transit Gateway </strong> and select the relevant <strong> Transit gateway ID </strong> . </p> </li> </ol> <p> After Transit gateway is established, we recommend switching your application connection string to the private endpoint. </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> If you've enabled the database's <a href="/docs/latest/operate/rc/security/cidr-whitelist/"> CIDR allow list </a> , you must also <a href="/docs/latest/operate/rc/security/cidr-whitelist/#define-cidr-allow-list"> add the Transit Gateway's IP address to the CIDR allow list </a> to connect to the database via the private endpoint. </div> </div> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rc/security/aws-transit-gateway/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/7.4/references/compatibility/commands/.html
<section class="prose w-full py-12 max-w-none"> <h1> Compatibility with Redis Community Edition commands </h1> <p class="text-lg -mt-5 mb-10"> Redis Community Edition commands compatible with Redis Enterprise. </p> <p> Learn which Redis Community Edition commands are compatible with Redis Enterprise Software and <a href="/docs/latest/operate/rc/"> Redis Cloud </a> . </p> <p> Select a command group for more details about compatibility with standard and Active-Active Redis Enterprise. </p> <table> <thead> <tr> <th style="text-align:left"> Command group </th> <th style="text-align:left"> Description </th> </tr> </thead> <tbody> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/7.4/references/compatibility/commands/cluster/"> Cluster management </a> </td> <td style="text-align:left"> Cluster management commands compatible with Redis Enterprise. </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/7.4/references/compatibility/commands/connection/"> Connection management </a> </td> <td style="text-align:left"> Connection management commands compatibility. </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/7.4/references/compatibility/commands/data-types/"> Data types </a> </td> <td style="text-align:left"> Data type commands compatibility (bitmaps, geospatial indices, hashes, HyperLogLogs, lists, sets, sorted sets, streams, strings). </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/7.4/references/compatibility/commands/generic/"> Keys (generic) </a> </td> <td style="text-align:left"> Generic key commands compatible with Redis Enterprise. </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/7.4/references/compatibility/commands/pub-sub/"> Pub/sub </a> </td> <td style="text-align:left"> Pub/sub commands compatibility. </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/7.4/references/compatibility/commands/scripting/"> Scripting </a> </td> <td style="text-align:left"> Scripting and function commands compatibility. </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/7.4/references/compatibility/commands/server/"> Server management </a> </td> <td style="text-align:left"> Server management commands compatibility. </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/operate/rs/7.4/references/compatibility/commands/transactions/"> Transactions </a> </td> <td style="text-align:left"> Transaction commands compatibility. </td> </tr> </tbody> </table> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/references/compatibility/commands/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/develop/data-types/sets/.html
<section class="prose w-full py-12"> <h1> Redis sets </h1> <p class="text-lg -mt-5 mb-10"> Introduction to Redis sets </p> <p> A Redis set is an unordered collection of unique strings (members). You can use Redis sets to efficiently: </p> <ul> <li> Track unique items (e.g., track all unique IP addresses accessing a given blog post). </li> <li> Represent relations (e.g., the set of all users with a given role). </li> <li> Perform common set operations such as intersection, unions, and differences. </li> </ul> <h2 id="basic-commands"> Basic commands </h2> <ul> <li> <a href="/docs/latest/commands/sadd/"> <code> SADD </code> </a> adds a new member to a set. </li> <li> <a href="/docs/latest/commands/srem/"> <code> SREM </code> </a> removes the specified member from the set. </li> <li> <a href="/docs/latest/commands/sismember/"> <code> SISMEMBER </code> </a> tests a string for set membership. </li> <li> <a href="/docs/latest/commands/sinter/"> <code> SINTER </code> </a> returns the set of members that two or more sets have in common (i.e., the intersection). </li> <li> <a href="/docs/latest/commands/scard/"> <code> SCARD </code> </a> returns the size (a.k.a. cardinality) of a set. </li> </ul> <p> See the <a href="/docs/latest/commands/?group=set"> complete list of set commands </a> . </p> <h2 id="examples"> Examples </h2> <ul> <li> <p> Store the sets of bikes racing in France and the USA. Note that if you add a member that already exists, it will be ignored. </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="sets_tutorial-stepsadd"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_sets_tutorial-stepsadd" name="sets_tutorial-stepsadd" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_sets_tutorial-stepsadd" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-sets_tutorial-stepsadd" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_sets_tutorial-stepsadd" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; SADD bikes:racing:france bike:1 </span></span><span class="line hl"><span class="cl">(integer) 1 </span></span><span class="line hl"><span class="cl">&gt; SADD bikes:racing:france bike:1 </span></span><span class="line hl"><span class="cl">(integer) 0 </span></span><span class="line hl"><span class="cl">&gt; SADD bikes:racing:france bike:2 bike:3 </span></span><span class="line hl"><span class="cl">(integer) 2 </span></span><span class="line hl"><span class="cl">&gt; SADD bikes:racing:usa bike:1 bike:4 </span></span><span class="line hl"><span class="cl">(integer) 2</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_sets_tutorial-stepsadd')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_sets_tutorial-stepsadd" name="sets_tutorial-stepsadd" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_sets_tutorial-stepsadd" title="Open example"> Python </label> <div aria-labelledby="tab-sets_tutorial-stepsadd" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_sets_tutorial-stepsadd" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for Set doc pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/sets/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sismember</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sismember</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sinter</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:1'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">scard</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">smembers</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:1', 'bike:2', 'bike:3'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sismember</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">smismember</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1, 1, 0]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sdiff</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:2', 'bike:3'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:italy"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sinter</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bikes:racing:italy"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:1'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sunion</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bikes:racing:italy"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:1', 'bike:2', 'bike:3', 'bike:4'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sdiff</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bikes:racing:italy"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sdiff</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:4'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sdiff</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:2', 'bike:3'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">srem</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res18</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">spop</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">smembers</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:2', 'bike:4', 'bike:5'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">srandmember</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res21</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:4</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_sets_tutorial-stepsadd')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_sets_tutorial-stepsadd" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_set.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_sets_tutorial-stepsadd" name="sets_tutorial-stepsadd" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_sets_tutorial-stepsadd" title="Open example"> Node.js </label> <div aria-labelledby="tab-sets_tutorial-stepsadd" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_sets_tutorial-stepsadd" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">createClient</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sIsMember</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sIsMember</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sInter</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; {'bike:1'} </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sCard</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sMembers</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:1', 'bike:2', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sIsMember</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">smIsMember</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [true, true, false] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res13</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sDiff</span><span class="p">([</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [ 'bike:2', 'bike:3' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:italy'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sInter</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="p">[</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bikes:racing:italy'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:1'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res15</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sUnion</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="p">[</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bikes:racing:italy'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:1', 'bike:2', 'bike:3', 'bike:4'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res16</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sDiff</span><span class="p">([</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bikes:racing:italy'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res17</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sDiff</span><span class="p">([</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bikes:racing:france'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:4'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res18</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sDiff</span><span class="p">([</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:2', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">debugger</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sRem</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sPop</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:3 or other random value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res21</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sMembers</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:2', 'bike:4', 'bike:5']; depends on previous result </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res22</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sRandMember</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:4 or other random value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_sets_tutorial-stepsadd')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_sets_tutorial-stepsadd" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-set.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_sets_tutorial-stepsadd" name="sets_tutorial-stepsadd" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_sets_tutorial-stepsadd" title="Open example"> Java </label> <div aria-labelledby="tab-sets_tutorial-stepsadd" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_sets_tutorial-stepsadd" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nn">io.redis.examples</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.junit.Test</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.List</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.Set</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.assertTrue</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.assertFalse</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.assertEquals</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">SetsExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sismember</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sismember</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sinter</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">scard</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">smembers</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1, bike:2, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sismember</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Boolean</span><span class="o">&gt;</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">smismember</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [true,true,false] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sdiff</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res13</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:italy"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sinter</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bikes:racing:italy"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res14</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sunion</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bikes:racing:italy"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res15</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1, bike:2, bike:3, bike:4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res16</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sdiff</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bikes:racing:italy"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res16</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sdiff</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res17</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sdiff</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">srem</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">spop</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res20</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res21</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">smembers</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res21</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2, bike:4, bike:5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res22</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">srandmember</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res22</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:4 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">close</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_sets_tutorial-stepsadd')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_sets_tutorial-stepsadd" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/SetsExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_sets_tutorial-stepsadd" name="sets_tutorial-stepsadd" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_sets_tutorial-stepsadd" title="Open example"> Go </label> <div aria-labelledby="tab-sets_tutorial-stepsadd" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_sets_tutorial-stepsadd" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_sadd</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_sismember</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SIsMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SIsMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_sinter</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SInter</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_scard</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SCard</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_saddsmembers</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SMembers</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1 bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_smismember</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SIsMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SMIsMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [true true false] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_sdiff</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SDiff</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_multisets</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:italy"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SInter</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bikes:racing:italy"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SUnion</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bikes:racing:italy"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1 bike:2 bike:3 bike:4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SDiff</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bikes:racing:italy"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SDiff</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SDiff</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_srem</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SRem</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;random element&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SMembers</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;remaining elements&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res22</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SRandMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;random element&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Testable examples not available because the test output </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// is not deterministic. </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_sets_tutorial-stepsadd')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_sets_tutorial-stepsadd" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/sets_example_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_sets_tutorial-stepsadd" name="sets_tutorial-stepsadd" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_sets_tutorial-stepsadd" title="Open example"> C# </label> <div aria-labelledby="tab-sets_tutorial-stepsadd" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_sets_tutorial-stepsadd" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">System.Data.Common</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Tests</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">StackExchange.Redis</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">SetsExample</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res3</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res4</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sadd' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetContains</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res5</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetContains</span><span class="p">(</span><span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sismember' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Intersect</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res9</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sinter' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetLength</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'scard' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetMembers</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res13</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:3, bike:2, bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sadd_smembers' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetContains</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res14</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span><span class="p">[]</span> <span class="n">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetContains</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res15</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; True, True, False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'smismember' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Difference</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res18</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:2, bike:3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sdiff' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res21</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:italy"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res22</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Intersect</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="s">"{bikes:racing}:italy"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res22</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res23</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Union</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="s">"{bikes:racing}:italy"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res23</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:1, bike:2, bike:3, bike:4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res24</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Difference</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="s">"{bikes:racing}:italy"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res24</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; &lt;empty set&gt;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res25</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Difference</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="s">"{bikes:racing}:france"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res25</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res26</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Difference</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res26</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:2, bike:3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'multisets' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res27</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res28</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetRemove</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res28</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res29</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetPop</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res29</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; bike:3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res30</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetMembers</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res30</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:2, bike:4, bike:5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res31</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetRandomMember</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res31</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; bike:4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'srem' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_sets_tutorial-stepsadd')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_sets_tutorial-stepsadd" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/SetsTutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <p> </p> </li> <li> <p> Check whether bike:1 or bike:2 are racing in the US. </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="sets_tutorial-stepsismember"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_sets_tutorial-stepsismember" name="sets_tutorial-stepsismember" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_sets_tutorial-stepsismember" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-sets_tutorial-stepsismember" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_sets_tutorial-stepsismember" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; SISMEMBER bikes:racing:usa bike:1 </span></span><span class="line hl"><span class="cl">(integer) 1 </span></span><span class="line hl"><span class="cl">&gt; SISMEMBER bikes:racing:usa bike:2 </span></span><span class="line hl"><span class="cl">(integer) 0</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_sets_tutorial-stepsismember')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_sets_tutorial-stepsismember" name="sets_tutorial-stepsismember" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_sets_tutorial-stepsismember" title="Open example"> Python </label> <div aria-labelledby="tab-sets_tutorial-stepsismember" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_sets_tutorial-stepsismember" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for Set doc pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/sets/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sismember</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sismember</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sinter</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:1'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">scard</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">smembers</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:1', 'bike:2', 'bike:3'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sismember</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">smismember</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1, 1, 0]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sdiff</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:2', 'bike:3'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:italy"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sinter</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bikes:racing:italy"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:1'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sunion</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bikes:racing:italy"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:1', 'bike:2', 'bike:3', 'bike:4'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sdiff</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bikes:racing:italy"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sdiff</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:4'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sdiff</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:2', 'bike:3'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">srem</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res18</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">spop</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">smembers</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:2', 'bike:4', 'bike:5'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">srandmember</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res21</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:4</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_sets_tutorial-stepsismember')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_sets_tutorial-stepsismember" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_set.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_sets_tutorial-stepsismember" name="sets_tutorial-stepsismember" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_sets_tutorial-stepsismember" title="Open example"> Node.js </label> <div aria-labelledby="tab-sets_tutorial-stepsismember" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_sets_tutorial-stepsismember" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">createClient</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sIsMember</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sIsMember</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sInter</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; {'bike:1'} </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sCard</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sMembers</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:1', 'bike:2', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sIsMember</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">smIsMember</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [true, true, false] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res13</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sDiff</span><span class="p">([</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [ 'bike:2', 'bike:3' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:italy'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sInter</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="p">[</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bikes:racing:italy'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:1'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res15</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sUnion</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="p">[</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bikes:racing:italy'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:1', 'bike:2', 'bike:3', 'bike:4'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res16</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sDiff</span><span class="p">([</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bikes:racing:italy'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res17</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sDiff</span><span class="p">([</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bikes:racing:france'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:4'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res18</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sDiff</span><span class="p">([</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:2', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">debugger</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sRem</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sPop</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:3 or other random value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res21</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sMembers</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:2', 'bike:4', 'bike:5']; depends on previous result </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res22</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sRandMember</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:4 or other random value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_sets_tutorial-stepsismember')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_sets_tutorial-stepsismember" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-set.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_sets_tutorial-stepsismember" name="sets_tutorial-stepsismember" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_sets_tutorial-stepsismember" title="Open example"> Java </label> <div aria-labelledby="tab-sets_tutorial-stepsismember" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_sets_tutorial-stepsismember" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nn">io.redis.examples</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.junit.Test</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.List</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.Set</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.assertTrue</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.assertFalse</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.assertEquals</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">SetsExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">boolean</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sismember</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">boolean</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sismember</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sinter</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">scard</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">smembers</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1, bike:2, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sismember</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Boolean</span><span class="o">&gt;</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">smismember</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [true,true,false] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sdiff</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res13</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:italy"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sinter</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bikes:racing:italy"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res14</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sunion</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bikes:racing:italy"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res15</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1, bike:2, bike:3, bike:4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res16</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sdiff</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bikes:racing:italy"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res16</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sdiff</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res17</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sdiff</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">srem</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">spop</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res20</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res21</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">smembers</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res21</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2, bike:4, bike:5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res22</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">srandmember</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res22</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:4 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">close</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_sets_tutorial-stepsismember')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_sets_tutorial-stepsismember" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/SetsExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_sets_tutorial-stepsismember" name="sets_tutorial-stepsismember" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_sets_tutorial-stepsismember" title="Open example"> Go </label> <div aria-labelledby="tab-sets_tutorial-stepsismember" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_sets_tutorial-stepsismember" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_sadd</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_sismember</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SIsMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SIsMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_sinter</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SInter</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_scard</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SCard</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_saddsmembers</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SMembers</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1 bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_smismember</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SIsMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SMIsMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [true true false] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_sdiff</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SDiff</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_multisets</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:italy"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SInter</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bikes:racing:italy"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SUnion</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bikes:racing:italy"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1 bike:2 bike:3 bike:4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SDiff</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bikes:racing:italy"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SDiff</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SDiff</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_srem</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SRem</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;random element&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SMembers</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;remaining elements&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res22</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SRandMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;random element&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Testable examples not available because the test output </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// is not deterministic. </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_sets_tutorial-stepsismember')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_sets_tutorial-stepsismember" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/sets_example_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_sets_tutorial-stepsismember" name="sets_tutorial-stepsismember" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_sets_tutorial-stepsismember" title="Open example"> C# </label> <div aria-labelledby="tab-sets_tutorial-stepsismember" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_sets_tutorial-stepsismember" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">System.Data.Common</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Tests</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">StackExchange.Redis</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">SetsExample</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res3</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res4</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sadd' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">bool</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetContains</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res5</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">bool</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetContains</span><span class="p">(</span><span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sismember' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Intersect</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res9</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sinter' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetLength</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'scard' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetMembers</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res13</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:3, bike:2, bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sadd_smembers' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetContains</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res14</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span><span class="p">[]</span> <span class="n">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetContains</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res15</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; True, True, False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'smismember' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Difference</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res18</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:2, bike:3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sdiff' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res21</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:italy"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res22</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Intersect</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="s">"{bikes:racing}:italy"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res22</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res23</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Union</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="s">"{bikes:racing}:italy"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res23</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:1, bike:2, bike:3, bike:4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res24</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Difference</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="s">"{bikes:racing}:italy"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res24</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; &lt;empty set&gt;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res25</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Difference</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="s">"{bikes:racing}:france"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res25</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res26</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Difference</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res26</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:2, bike:3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'multisets' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res27</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res28</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetRemove</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res28</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res29</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetPop</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res29</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; bike:3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res30</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetMembers</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res30</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:2, bike:4, bike:5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res31</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetRandomMember</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res31</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; bike:4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'srem' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_sets_tutorial-stepsismember')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_sets_tutorial-stepsismember" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/SetsTutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <p> </p> </li> <li> <p> Which bikes are competing in both races? </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="sets_tutorial-stepsinter"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_sets_tutorial-stepsinter" name="sets_tutorial-stepsinter" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_sets_tutorial-stepsinter" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-sets_tutorial-stepsinter" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_sets_tutorial-stepsinter" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; SINTER bikes:racing:france bikes:racing:usa </span></span><span class="line hl"><span class="cl">1) "bike:1"</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_sets_tutorial-stepsinter')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_sets_tutorial-stepsinter" name="sets_tutorial-stepsinter" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_sets_tutorial-stepsinter" title="Open example"> Python </label> <div aria-labelledby="tab-sets_tutorial-stepsinter" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_sets_tutorial-stepsinter" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for Set doc pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/sets/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sismember</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sismember</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sinter</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:1'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">scard</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">smembers</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:1', 'bike:2', 'bike:3'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sismember</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">smismember</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1, 1, 0]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sdiff</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:2', 'bike:3'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:italy"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sinter</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bikes:racing:italy"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:1'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sunion</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bikes:racing:italy"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:1', 'bike:2', 'bike:3', 'bike:4'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sdiff</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bikes:racing:italy"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sdiff</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:4'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sdiff</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:2', 'bike:3'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">srem</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res18</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">spop</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">smembers</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:2', 'bike:4', 'bike:5'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">srandmember</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res21</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:4</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_sets_tutorial-stepsinter')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_sets_tutorial-stepsinter" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_set.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_sets_tutorial-stepsinter" name="sets_tutorial-stepsinter" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_sets_tutorial-stepsinter" title="Open example"> Node.js </label> <div aria-labelledby="tab-sets_tutorial-stepsinter" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_sets_tutorial-stepsinter" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">createClient</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sIsMember</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sIsMember</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sInter</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; {'bike:1'} </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sCard</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sMembers</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:1', 'bike:2', 'bike:3'] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sIsMember</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">smIsMember</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [true, true, false] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line hl"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res13</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sDiff</span><span class="p">([</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">])</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [ 'bike:2', 'bike:3' ] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line hl"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line hl"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:italy'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sInter</span><span class="p">(</span> </span></span><span class="line hl"><span class="cl"> <span class="p">[</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bikes:racing:italy'</span><span class="p">]</span> </span></span><span class="line hl"><span class="cl"><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:1'] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res15</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sUnion</span><span class="p">(</span> </span></span><span class="line hl"><span class="cl"> <span class="p">[</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bikes:racing:italy'</span><span class="p">]</span> </span></span><span class="line hl"><span class="cl"><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:1', 'bike:2', 'bike:3', 'bike:4'] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res16</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sDiff</span><span class="p">([</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bikes:racing:italy'</span><span class="p">])</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res17</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sDiff</span><span class="p">([</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bikes:racing:france'</span><span class="p">])</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:4'] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res18</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sDiff</span><span class="p">([</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">])</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:2', 'bike:3'] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">debugger</span><span class="p">;</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">])</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sRem</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sPop</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:3 or other random value </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res21</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sMembers</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:2', 'bike:4', 'bike:5']; depends on previous result </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res22</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sRandMember</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:4 or other random value </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_sets_tutorial-stepsinter')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_sets_tutorial-stepsinter" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-set.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_sets_tutorial-stepsinter" name="sets_tutorial-stepsinter" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_sets_tutorial-stepsinter" title="Open example"> Java </label> <div aria-labelledby="tab-sets_tutorial-stepsinter" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_sets_tutorial-stepsinter" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nn">io.redis.examples</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.junit.Test</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.List</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.Set</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.assertTrue</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.assertFalse</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.assertEquals</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">SetsExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sismember</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sismember</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sinter</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">scard</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">smembers</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1, bike:2, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sismember</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Boolean</span><span class="o">&gt;</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">smismember</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [true,true,false] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sdiff</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res13</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:italy"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sinter</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bikes:racing:italy"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res14</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sunion</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bikes:racing:italy"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res15</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1, bike:2, bike:3, bike:4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res16</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sdiff</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bikes:racing:italy"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res16</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sdiff</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res17</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sdiff</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">srem</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">spop</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res20</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res21</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">smembers</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res21</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2, bike:4, bike:5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res22</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">srandmember</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res22</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:4 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">close</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_sets_tutorial-stepsinter')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_sets_tutorial-stepsinter" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/SetsExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_sets_tutorial-stepsinter" name="sets_tutorial-stepsinter" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_sets_tutorial-stepsinter" title="Open example"> Go </label> <div aria-labelledby="tab-sets_tutorial-stepsinter" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_sets_tutorial-stepsinter" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_sadd</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_sismember</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SIsMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SIsMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_sinter</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SInter</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_scard</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SCard</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_saddsmembers</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SMembers</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1 bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_smismember</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SIsMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SMIsMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [true true false] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_sdiff</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SDiff</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_multisets</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:italy"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SInter</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bikes:racing:italy"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SUnion</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bikes:racing:italy"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1 bike:2 bike:3 bike:4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SDiff</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bikes:racing:italy"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SDiff</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SDiff</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_srem</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SRem</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;random element&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SMembers</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;remaining elements&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res22</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SRandMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;random element&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Testable examples not available because the test output </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// is not deterministic. </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_sets_tutorial-stepsinter')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_sets_tutorial-stepsinter" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/sets_example_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_sets_tutorial-stepsinter" name="sets_tutorial-stepsinter" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_sets_tutorial-stepsinter" title="Open example"> C# </label> <div aria-labelledby="tab-sets_tutorial-stepsinter" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_sets_tutorial-stepsinter" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">System.Data.Common</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Tests</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">StackExchange.Redis</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">SetsExample</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res3</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res4</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sadd' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetContains</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res5</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetContains</span><span class="p">(</span><span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sismember' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Intersect</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res9</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sinter' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetLength</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'scard' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetMembers</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res13</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:3, bike:2, bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sadd_smembers' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetContains</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res14</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span><span class="p">[]</span> <span class="n">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetContains</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res15</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; True, True, False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'smismember' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Difference</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res18</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:2, bike:3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sdiff' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res21</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:italy"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res22</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Intersect</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="s">"{bikes:racing}:italy"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res22</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res23</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Union</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="s">"{bikes:racing}:italy"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res23</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:1, bike:2, bike:3, bike:4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res24</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Difference</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="s">"{bikes:racing}:italy"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res24</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; &lt;empty set&gt;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res25</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Difference</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="s">"{bikes:racing}:france"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res25</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res26</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Difference</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res26</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:2, bike:3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'multisets' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res27</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res28</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetRemove</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res28</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res29</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetPop</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res29</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; bike:3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res30</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetMembers</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res30</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:2, bike:4, bike:5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res31</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetRandomMember</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res31</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; bike:4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'srem' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_sets_tutorial-stepsinter')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_sets_tutorial-stepsinter" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/SetsTutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <p> </p> </li> <li> <p> How many bikes are racing in France? </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="sets_tutorial-stepscard"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_sets_tutorial-stepscard" name="sets_tutorial-stepscard" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_sets_tutorial-stepscard" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-sets_tutorial-stepscard" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_sets_tutorial-stepscard" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; SCARD bikes:racing:france </span></span><span class="line hl"><span class="cl">(integer) 3</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_sets_tutorial-stepscard')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_sets_tutorial-stepscard" name="sets_tutorial-stepscard" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_sets_tutorial-stepscard" title="Open example"> Python </label> <div aria-labelledby="tab-sets_tutorial-stepscard" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_sets_tutorial-stepscard" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for Set doc pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/sets/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sismember</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sismember</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sinter</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:1'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">scard</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">smembers</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:1', 'bike:2', 'bike:3'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sismember</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">smismember</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1, 1, 0]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sdiff</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:2', 'bike:3'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:italy"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sinter</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bikes:racing:italy"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:1'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sunion</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bikes:racing:italy"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:1', 'bike:2', 'bike:3', 'bike:4'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sdiff</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bikes:racing:italy"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sdiff</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:4'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sdiff</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:2', 'bike:3'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">srem</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res18</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">spop</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">smembers</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:2', 'bike:4', 'bike:5'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">srandmember</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res21</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:4</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_sets_tutorial-stepscard')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_sets_tutorial-stepscard" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_set.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_sets_tutorial-stepscard" name="sets_tutorial-stepscard" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_sets_tutorial-stepscard" title="Open example"> Node.js </label> <div aria-labelledby="tab-sets_tutorial-stepscard" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_sets_tutorial-stepscard" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">createClient</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sIsMember</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sIsMember</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sInter</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; {'bike:1'} </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sCard</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sMembers</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:1', 'bike:2', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sIsMember</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">smIsMember</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [true, true, false] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res13</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sDiff</span><span class="p">([</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [ 'bike:2', 'bike:3' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:italy'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sInter</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="p">[</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bikes:racing:italy'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:1'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res15</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sUnion</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="p">[</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bikes:racing:italy'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:1', 'bike:2', 'bike:3', 'bike:4'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res16</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sDiff</span><span class="p">([</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bikes:racing:italy'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res17</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sDiff</span><span class="p">([</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bikes:racing:france'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:4'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res18</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sDiff</span><span class="p">([</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:2', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">debugger</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sRem</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sPop</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:3 or other random value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res21</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sMembers</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:2', 'bike:4', 'bike:5']; depends on previous result </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res22</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sRandMember</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:4 or other random value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_sets_tutorial-stepscard')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_sets_tutorial-stepscard" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-set.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_sets_tutorial-stepscard" name="sets_tutorial-stepscard" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_sets_tutorial-stepscard" title="Open example"> Java </label> <div aria-labelledby="tab-sets_tutorial-stepscard" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_sets_tutorial-stepscard" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nn">io.redis.examples</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.junit.Test</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.List</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.Set</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.assertTrue</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.assertFalse</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.assertEquals</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">SetsExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sismember</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sismember</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sinter</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">scard</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">smembers</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1, bike:2, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sismember</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Boolean</span><span class="o">&gt;</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">smismember</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [true,true,false] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sdiff</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res13</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:italy"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sinter</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bikes:racing:italy"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res14</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sunion</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bikes:racing:italy"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res15</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1, bike:2, bike:3, bike:4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res16</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sdiff</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bikes:racing:italy"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res16</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sdiff</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res17</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sdiff</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">srem</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">spop</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res20</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res21</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">smembers</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res21</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2, bike:4, bike:5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res22</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">srandmember</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res22</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:4 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">close</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_sets_tutorial-stepscard')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_sets_tutorial-stepscard" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/SetsExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_sets_tutorial-stepscard" name="sets_tutorial-stepscard" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_sets_tutorial-stepscard" title="Open example"> Go </label> <div aria-labelledby="tab-sets_tutorial-stepscard" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_sets_tutorial-stepscard" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_sadd</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_sismember</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SIsMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SIsMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_sinter</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SInter</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_scard</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SCard</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_saddsmembers</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SMembers</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1 bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_smismember</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SIsMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SMIsMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [true true false] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_sdiff</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SDiff</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_multisets</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:italy"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SInter</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bikes:racing:italy"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SUnion</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bikes:racing:italy"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1 bike:2 bike:3 bike:4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SDiff</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bikes:racing:italy"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SDiff</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SDiff</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_srem</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SRem</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;random element&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SMembers</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;remaining elements&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res22</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SRandMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;random element&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Testable examples not available because the test output </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// is not deterministic. </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_sets_tutorial-stepscard')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_sets_tutorial-stepscard" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/sets_example_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_sets_tutorial-stepscard" name="sets_tutorial-stepscard" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_sets_tutorial-stepscard" title="Open example"> C# </label> <div aria-labelledby="tab-sets_tutorial-stepscard" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_sets_tutorial-stepscard" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">System.Data.Common</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Tests</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">StackExchange.Redis</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">SetsExample</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res3</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res4</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sadd' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetContains</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res5</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetContains</span><span class="p">(</span><span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sismember' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Intersect</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res9</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sinter' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetLength</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'scard' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetMembers</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res13</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:3, bike:2, bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sadd_smembers' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetContains</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res14</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span><span class="p">[]</span> <span class="n">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetContains</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res15</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; True, True, False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'smismember' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Difference</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res18</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:2, bike:3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sdiff' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res21</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:italy"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res22</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Intersect</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="s">"{bikes:racing}:italy"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res22</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res23</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Union</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="s">"{bikes:racing}:italy"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res23</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:1, bike:2, bike:3, bike:4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res24</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Difference</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="s">"{bikes:racing}:italy"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res24</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; &lt;empty set&gt;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res25</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Difference</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="s">"{bikes:racing}:france"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res25</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res26</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Difference</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res26</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:2, bike:3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'multisets' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res27</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res28</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetRemove</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res28</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res29</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetPop</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res29</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; bike:3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res30</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetMembers</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res30</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:2, bike:4, bike:5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res31</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetRandomMember</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res31</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; bike:4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'srem' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_sets_tutorial-stepscard')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_sets_tutorial-stepscard" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/SetsTutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <p> </p> </li> </ul> <h2 id="tutorial"> Tutorial </h2> <p> The <a href="/docs/latest/commands/sadd/"> <code> SADD </code> </a> command adds new elements to a set. It's also possible to do a number of other operations against sets like testing if a given element already exists, performing the intersection, union or difference between multiple sets, and so forth. </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="sets_tutorial-stepsadd_smembers"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_sets_tutorial-stepsadd_smembers" name="sets_tutorial-stepsadd_smembers" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_sets_tutorial-stepsadd_smembers" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-sets_tutorial-stepsadd_smembers" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_sets_tutorial-stepsadd_smembers" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; SADD bikes:racing:france bike:1 bike:2 bike:3 </span></span><span class="line hl"><span class="cl">(integer) 3 </span></span><span class="line hl"><span class="cl">&gt; SMEMBERS bikes:racing:france </span></span><span class="line hl"><span class="cl">1) bike:3 </span></span><span class="line hl"><span class="cl">2) bike:1 </span></span><span class="line hl"><span class="cl">3) bike:2</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_sets_tutorial-stepsadd_smembers')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_sets_tutorial-stepsadd_smembers" name="sets_tutorial-stepsadd_smembers" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_sets_tutorial-stepsadd_smembers" title="Open example"> Python </label> <div aria-labelledby="tab-sets_tutorial-stepsadd_smembers" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_sets_tutorial-stepsadd_smembers" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for Set doc pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/sets/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sismember</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sismember</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sinter</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:1'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">scard</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">smembers</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:1', 'bike:2', 'bike:3'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sismember</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">smismember</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1, 1, 0]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sdiff</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:2', 'bike:3'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:italy"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sinter</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bikes:racing:italy"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:1'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sunion</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bikes:racing:italy"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:1', 'bike:2', 'bike:3', 'bike:4'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sdiff</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bikes:racing:italy"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sdiff</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:4'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sdiff</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:2', 'bike:3'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">srem</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res18</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">spop</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">smembers</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:2', 'bike:4', 'bike:5'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">srandmember</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res21</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:4</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_sets_tutorial-stepsadd_smembers')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_sets_tutorial-stepsadd_smembers" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_set.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_sets_tutorial-stepsadd_smembers" name="sets_tutorial-stepsadd_smembers" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_sets_tutorial-stepsadd_smembers" title="Open example"> Node.js </label> <div aria-labelledby="tab-sets_tutorial-stepsadd_smembers" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_sets_tutorial-stepsadd_smembers" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">createClient</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sIsMember</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sIsMember</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sInter</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; {'bike:1'} </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sCard</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sMembers</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:1', 'bike:2', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sIsMember</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">smIsMember</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [true, true, false] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res13</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sDiff</span><span class="p">([</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [ 'bike:2', 'bike:3' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:italy'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sInter</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="p">[</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bikes:racing:italy'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:1'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res15</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sUnion</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="p">[</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bikes:racing:italy'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:1', 'bike:2', 'bike:3', 'bike:4'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res16</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sDiff</span><span class="p">([</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bikes:racing:italy'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res17</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sDiff</span><span class="p">([</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bikes:racing:france'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:4'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res18</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sDiff</span><span class="p">([</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:2', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">debugger</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sRem</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sPop</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:3 or other random value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res21</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sMembers</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:2', 'bike:4', 'bike:5']; depends on previous result </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res22</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sRandMember</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:4 or other random value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_sets_tutorial-stepsadd_smembers')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_sets_tutorial-stepsadd_smembers" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-set.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_sets_tutorial-stepsadd_smembers" name="sets_tutorial-stepsadd_smembers" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_sets_tutorial-stepsadd_smembers" title="Open example"> Java </label> <div aria-labelledby="tab-sets_tutorial-stepsadd_smembers" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_sets_tutorial-stepsadd_smembers" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nn">io.redis.examples</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.junit.Test</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.List</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.Set</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.assertTrue</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.assertFalse</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.assertEquals</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">SetsExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sismember</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sismember</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sinter</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">scard</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">smembers</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1, bike:2, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sismember</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Boolean</span><span class="o">&gt;</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">smismember</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [true,true,false] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sdiff</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res13</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:italy"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sinter</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bikes:racing:italy"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res14</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sunion</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bikes:racing:italy"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res15</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1, bike:2, bike:3, bike:4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res16</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sdiff</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bikes:racing:italy"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res16</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sdiff</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res17</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sdiff</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">srem</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">spop</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res20</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res21</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">smembers</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res21</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2, bike:4, bike:5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res22</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">srandmember</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res22</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:4 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">close</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_sets_tutorial-stepsadd_smembers')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_sets_tutorial-stepsadd_smembers" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/SetsExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_sets_tutorial-stepsadd_smembers" name="sets_tutorial-stepsadd_smembers" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_sets_tutorial-stepsadd_smembers" title="Open example"> Go </label> <div aria-labelledby="tab-sets_tutorial-stepsadd_smembers" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_sets_tutorial-stepsadd_smembers" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_sadd</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_sismember</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SIsMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SIsMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_sinter</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SInter</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_scard</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SCard</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_saddsmembers</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SMembers</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1 bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_smismember</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SIsMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SMIsMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [true true false] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_sdiff</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SDiff</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_multisets</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:italy"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SInter</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bikes:racing:italy"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SUnion</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bikes:racing:italy"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1 bike:2 bike:3 bike:4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SDiff</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bikes:racing:italy"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SDiff</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SDiff</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_srem</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SRem</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;random element&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SMembers</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;remaining elements&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res22</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SRandMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;random element&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Testable examples not available because the test output </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// is not deterministic. </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_sets_tutorial-stepsadd_smembers')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_sets_tutorial-stepsadd_smembers" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/sets_example_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_sets_tutorial-stepsadd_smembers" name="sets_tutorial-stepsadd_smembers" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_sets_tutorial-stepsadd_smembers" title="Open example"> C# </label> <div aria-labelledby="tab-sets_tutorial-stepsadd_smembers" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_sets_tutorial-stepsadd_smembers" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">System.Data.Common</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Tests</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">StackExchange.Redis</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">SetsExample</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res3</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res4</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sadd' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetContains</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res5</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetContains</span><span class="p">(</span><span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sismember' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Intersect</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res9</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sinter' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetLength</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'scard' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetMembers</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res13</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:3, bike:2, bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sadd_smembers' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetContains</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res14</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span><span class="p">[]</span> <span class="n">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetContains</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res15</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; True, True, False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'smismember' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Difference</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res18</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:2, bike:3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sdiff' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res21</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:italy"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res22</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Intersect</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="s">"{bikes:racing}:italy"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res22</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res23</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Union</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="s">"{bikes:racing}:italy"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res23</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:1, bike:2, bike:3, bike:4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res24</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Difference</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="s">"{bikes:racing}:italy"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res24</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; &lt;empty set&gt;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res25</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Difference</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="s">"{bikes:racing}:france"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res25</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res26</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Difference</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res26</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:2, bike:3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'multisets' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res27</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res28</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetRemove</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res28</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res29</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetPop</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res29</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; bike:3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res30</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetMembers</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res30</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:2, bike:4, bike:5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res31</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetRandomMember</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res31</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; bike:4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'srem' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_sets_tutorial-stepsadd_smembers')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_sets_tutorial-stepsadd_smembers" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/SetsTutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <p> Here I've added three elements to my set and told Redis to return all the elements. There is no order guarantee with a set. Redis is free to return the elements in any order at every call. </p> <p> Redis has commands to test for set membership. These commands can be used on single as well as multiple items: </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="sets_tutorial-stepsmismember"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_sets_tutorial-stepsmismember" name="sets_tutorial-stepsmismember" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_sets_tutorial-stepsmismember" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-sets_tutorial-stepsmismember" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_sets_tutorial-stepsmismember" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; SISMEMBER bikes:racing:france bike:1 </span></span><span class="line hl"><span class="cl">(integer) 1 </span></span><span class="line hl"><span class="cl">&gt; SMISMEMBER bikes:racing:france bike:2 bike:3 bike:4 </span></span><span class="line hl"><span class="cl">1) (integer) 1 </span></span><span class="line hl"><span class="cl">2) (integer) 1 </span></span><span class="line hl"><span class="cl">3) (integer) 0</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_sets_tutorial-stepsmismember')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_sets_tutorial-stepsmismember" name="sets_tutorial-stepsmismember" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_sets_tutorial-stepsmismember" title="Open example"> Python </label> <div aria-labelledby="tab-sets_tutorial-stepsmismember" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_sets_tutorial-stepsmismember" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for Set doc pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/sets/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sismember</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sismember</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sinter</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:1'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">scard</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">smembers</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:1', 'bike:2', 'bike:3'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sismember</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">smismember</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1, 1, 0]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sdiff</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:2', 'bike:3'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:italy"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sinter</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bikes:racing:italy"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:1'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sunion</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bikes:racing:italy"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:1', 'bike:2', 'bike:3', 'bike:4'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sdiff</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bikes:racing:italy"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sdiff</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:4'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sdiff</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:2', 'bike:3'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">srem</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res18</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">spop</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">smembers</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:2', 'bike:4', 'bike:5'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">srandmember</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res21</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:4</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_sets_tutorial-stepsmismember')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_sets_tutorial-stepsmismember" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_set.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_sets_tutorial-stepsmismember" name="sets_tutorial-stepsmismember" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_sets_tutorial-stepsmismember" title="Open example"> Node.js </label> <div aria-labelledby="tab-sets_tutorial-stepsmismember" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_sets_tutorial-stepsmismember" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">createClient</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sIsMember</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sIsMember</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sInter</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; {'bike:1'} </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sCard</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sMembers</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:1', 'bike:2', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sIsMember</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">smIsMember</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [true, true, false] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res13</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sDiff</span><span class="p">([</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [ 'bike:2', 'bike:3' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:italy'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sInter</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="p">[</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bikes:racing:italy'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:1'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res15</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sUnion</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="p">[</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bikes:racing:italy'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:1', 'bike:2', 'bike:3', 'bike:4'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res16</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sDiff</span><span class="p">([</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bikes:racing:italy'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res17</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sDiff</span><span class="p">([</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bikes:racing:france'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:4'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res18</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sDiff</span><span class="p">([</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:2', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">debugger</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sRem</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sPop</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:3 or other random value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res21</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sMembers</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:2', 'bike:4', 'bike:5']; depends on previous result </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res22</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sRandMember</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:4 or other random value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_sets_tutorial-stepsmismember')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_sets_tutorial-stepsmismember" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-set.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_sets_tutorial-stepsmismember" name="sets_tutorial-stepsmismember" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_sets_tutorial-stepsmismember" title="Open example"> Java </label> <div aria-labelledby="tab-sets_tutorial-stepsmismember" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_sets_tutorial-stepsmismember" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nn">io.redis.examples</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.junit.Test</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.List</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.Set</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.assertTrue</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.assertFalse</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.assertEquals</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">SetsExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sismember</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sismember</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sinter</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">scard</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">smembers</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1, bike:2, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">boolean</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sismember</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Boolean</span><span class="o">&gt;</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">smismember</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [true,true,false] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sdiff</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res13</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:italy"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sinter</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bikes:racing:italy"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res14</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sunion</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bikes:racing:italy"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res15</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1, bike:2, bike:3, bike:4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res16</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sdiff</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bikes:racing:italy"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res16</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sdiff</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res17</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sdiff</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">srem</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">spop</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res20</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res21</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">smembers</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res21</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2, bike:4, bike:5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res22</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">srandmember</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res22</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:4 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">close</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_sets_tutorial-stepsmismember')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_sets_tutorial-stepsmismember" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/SetsExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_sets_tutorial-stepsmismember" name="sets_tutorial-stepsmismember" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_sets_tutorial-stepsmismember" title="Open example"> Go </label> <div aria-labelledby="tab-sets_tutorial-stepsmismember" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_sets_tutorial-stepsmismember" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_sadd</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_sismember</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SIsMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SIsMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_sinter</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SInter</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_scard</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SCard</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_saddsmembers</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SMembers</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1 bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_smismember</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SIsMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SMIsMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [true true false] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_sdiff</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SDiff</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_multisets</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:italy"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SInter</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bikes:racing:italy"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SUnion</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bikes:racing:italy"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1 bike:2 bike:3 bike:4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SDiff</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bikes:racing:italy"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SDiff</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SDiff</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_srem</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SRem</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;random element&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SMembers</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;remaining elements&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res22</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SRandMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;random element&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Testable examples not available because the test output </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// is not deterministic. </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_sets_tutorial-stepsmismember')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_sets_tutorial-stepsmismember" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/sets_example_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_sets_tutorial-stepsmismember" name="sets_tutorial-stepsmismember" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_sets_tutorial-stepsmismember" title="Open example"> C# </label> <div aria-labelledby="tab-sets_tutorial-stepsmismember" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_sets_tutorial-stepsmismember" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">System.Data.Common</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Tests</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">StackExchange.Redis</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">SetsExample</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res3</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res4</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sadd' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetContains</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res5</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetContains</span><span class="p">(</span><span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sismember' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Intersect</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res9</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sinter' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetLength</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'scard' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetMembers</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res13</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:3, bike:2, bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sadd_smembers' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">bool</span> <span class="n">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetContains</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res14</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">bool</span><span class="p">[]</span> <span class="n">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetContains</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res15</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; True, True, False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'smismember' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Difference</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res18</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:2, bike:3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sdiff' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res21</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:italy"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res22</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Intersect</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="s">"{bikes:racing}:italy"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res22</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res23</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Union</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="s">"{bikes:racing}:italy"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res23</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:1, bike:2, bike:3, bike:4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res24</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Difference</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="s">"{bikes:racing}:italy"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res24</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; &lt;empty set&gt;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res25</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Difference</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="s">"{bikes:racing}:france"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res25</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res26</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Difference</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res26</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:2, bike:3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'multisets' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res27</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res28</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetRemove</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res28</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res29</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetPop</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res29</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; bike:3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res30</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetMembers</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res30</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:2, bike:4, bike:5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res31</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetRandomMember</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res31</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; bike:4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'srem' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_sets_tutorial-stepsmismember')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_sets_tutorial-stepsmismember" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/SetsTutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <p> We can also find the difference between two sets. For instance, we may want to know which bikes are racing in France but not in the USA: </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="sets_tutorial-stepsdiff"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_sets_tutorial-stepsdiff" name="sets_tutorial-stepsdiff" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_sets_tutorial-stepsdiff" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-sets_tutorial-stepsdiff" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_sets_tutorial-stepsdiff" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; SADD bikes:racing:usa bike:1 bike:4 </span></span><span class="line hl"><span class="cl">(integer) 2 </span></span><span class="line hl"><span class="cl">&gt; SDIFF bikes:racing:france bikes:racing:usa </span></span><span class="line hl"><span class="cl">1) "bike:3" </span></span><span class="line hl"><span class="cl">2) "bike:2"</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_sets_tutorial-stepsdiff')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_sets_tutorial-stepsdiff" name="sets_tutorial-stepsdiff" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_sets_tutorial-stepsdiff" title="Open example"> Python </label> <div aria-labelledby="tab-sets_tutorial-stepsdiff" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_sets_tutorial-stepsdiff" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for Set doc pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/sets/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sismember</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sismember</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sinter</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:1'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">scard</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">smembers</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:1', 'bike:2', 'bike:3'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sismember</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">smismember</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1, 1, 0]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sdiff</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:2', 'bike:3'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:italy"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sinter</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bikes:racing:italy"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:1'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sunion</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bikes:racing:italy"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:1', 'bike:2', 'bike:3', 'bike:4'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sdiff</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bikes:racing:italy"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sdiff</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:4'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sdiff</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:2', 'bike:3'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">srem</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res18</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">spop</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">smembers</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:2', 'bike:4', 'bike:5'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">srandmember</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res21</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:4</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_sets_tutorial-stepsdiff')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_sets_tutorial-stepsdiff" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_set.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_sets_tutorial-stepsdiff" name="sets_tutorial-stepsdiff" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_sets_tutorial-stepsdiff" title="Open example"> Node.js </label> <div aria-labelledby="tab-sets_tutorial-stepsdiff" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_sets_tutorial-stepsdiff" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">createClient</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sIsMember</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sIsMember</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sInter</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; {'bike:1'} </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sCard</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sMembers</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:1', 'bike:2', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sIsMember</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">smIsMember</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [true, true, false] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line hl"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res13</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sDiff</span><span class="p">([</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">])</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [ 'bike:2', 'bike:3' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:italy'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sInter</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="p">[</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bikes:racing:italy'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:1'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res15</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sUnion</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="p">[</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bikes:racing:italy'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:1', 'bike:2', 'bike:3', 'bike:4'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res16</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sDiff</span><span class="p">([</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bikes:racing:italy'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res17</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sDiff</span><span class="p">([</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bikes:racing:france'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:4'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res18</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sDiff</span><span class="p">([</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:2', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">debugger</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sRem</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sPop</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:3 or other random value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res21</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sMembers</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:2', 'bike:4', 'bike:5']; depends on previous result </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res22</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sRandMember</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:4 or other random value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_sets_tutorial-stepsdiff')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_sets_tutorial-stepsdiff" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-set.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_sets_tutorial-stepsdiff" name="sets_tutorial-stepsdiff" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_sets_tutorial-stepsdiff" title="Open example"> Java </label> <div aria-labelledby="tab-sets_tutorial-stepsdiff" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_sets_tutorial-stepsdiff" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nn">io.redis.examples</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.junit.Test</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.List</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.Set</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.assertTrue</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.assertFalse</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.assertEquals</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">SetsExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sismember</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sismember</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sinter</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">scard</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">smembers</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1, bike:2, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sismember</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Boolean</span><span class="o">&gt;</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">smismember</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [true,true,false] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sdiff</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res13</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2, bike:3] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:italy"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sinter</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bikes:racing:italy"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res14</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sunion</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bikes:racing:italy"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res15</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1, bike:2, bike:3, bike:4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res16</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sdiff</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bikes:racing:italy"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res16</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sdiff</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res17</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sdiff</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">srem</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">spop</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res20</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res21</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">smembers</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res21</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2, bike:4, bike:5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res22</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">srandmember</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res22</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:4 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">close</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_sets_tutorial-stepsdiff')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_sets_tutorial-stepsdiff" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/SetsExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_sets_tutorial-stepsdiff" name="sets_tutorial-stepsdiff" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_sets_tutorial-stepsdiff" title="Open example"> Go </label> <div aria-labelledby="tab-sets_tutorial-stepsdiff" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_sets_tutorial-stepsdiff" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_sadd</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_sismember</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SIsMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SIsMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_sinter</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SInter</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_scard</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SCard</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_saddsmembers</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SMembers</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1 bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_smismember</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SIsMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SMIsMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [true true false] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_sdiff</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SDiff</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_multisets</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:italy"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SInter</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bikes:racing:italy"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SUnion</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bikes:racing:italy"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1 bike:2 bike:3 bike:4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SDiff</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bikes:racing:italy"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SDiff</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SDiff</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_srem</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SRem</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;random element&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SMembers</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;remaining elements&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res22</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SRandMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;random element&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Testable examples not available because the test output </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// is not deterministic. </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_sets_tutorial-stepsdiff')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_sets_tutorial-stepsdiff" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/sets_example_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_sets_tutorial-stepsdiff" name="sets_tutorial-stepsdiff" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_sets_tutorial-stepsdiff" title="Open example"> C# </label> <div aria-labelledby="tab-sets_tutorial-stepsdiff" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_sets_tutorial-stepsdiff" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">System.Data.Common</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Tests</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">StackExchange.Redis</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">SetsExample</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res3</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res4</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sadd' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetContains</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res5</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetContains</span><span class="p">(</span><span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sismember' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Intersect</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res9</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sinter' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetLength</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'scard' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetMembers</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res13</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:3, bike:2, bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sadd_smembers' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetContains</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res14</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span><span class="p">[]</span> <span class="n">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetContains</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res15</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; True, True, False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'smismember' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Difference</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res18</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:2, bike:3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sdiff' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res21</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:italy"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res22</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Intersect</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="s">"{bikes:racing}:italy"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res22</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res23</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Union</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="s">"{bikes:racing}:italy"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res23</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:1, bike:2, bike:3, bike:4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res24</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Difference</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="s">"{bikes:racing}:italy"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res24</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; &lt;empty set&gt;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res25</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Difference</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="s">"{bikes:racing}:france"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res25</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res26</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Difference</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res26</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:2, bike:3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'multisets' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res27</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res28</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetRemove</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res28</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res29</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetPop</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res29</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; bike:3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res30</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetMembers</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res30</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:2, bike:4, bike:5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res31</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetRandomMember</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res31</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; bike:4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'srem' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_sets_tutorial-stepsdiff')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_sets_tutorial-stepsdiff" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/SetsTutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <p> There are other non trivial operations that are still easy to implement using the right Redis commands. For instance we may want a list of all the bikes racing in France, the USA, and some other races. We can do this using the <a href="/docs/latest/commands/sinter/"> <code> SINTER </code> </a> command, which performs the intersection between different sets. In addition to intersection you can also perform unions, difference, and more. For example if we add a third race we can see some of these commands in action: </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="sets_tutorial-stepmultisets"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_sets_tutorial-stepmultisets" name="sets_tutorial-stepmultisets" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_sets_tutorial-stepmultisets" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-sets_tutorial-stepmultisets" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_sets_tutorial-stepmultisets" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; SADD bikes:racing:france bike:1 bike:2 bike:3 </span></span><span class="line hl"><span class="cl">(integer) 3 </span></span><span class="line hl"><span class="cl">&gt; SADD bikes:racing:usa bike:1 bike:4 </span></span><span class="line hl"><span class="cl">(integer) 2 </span></span><span class="line hl"><span class="cl">&gt; SADD bikes:racing:italy bike:1 bike:2 bike:3 bike:4 </span></span><span class="line hl"><span class="cl">(integer) 4 </span></span><span class="line hl"><span class="cl">&gt; SINTER bikes:racing:france bikes:racing:usa bikes:racing:italy </span></span><span class="line hl"><span class="cl">1) "bike:1" </span></span><span class="line hl"><span class="cl">&gt; SUNION bikes:racing:france bikes:racing:usa bikes:racing:italy </span></span><span class="line hl"><span class="cl">1) "bike:2" </span></span><span class="line hl"><span class="cl">2) "bike:1" </span></span><span class="line hl"><span class="cl">3) "bike:4" </span></span><span class="line hl"><span class="cl">4) "bike:3" </span></span><span class="line hl"><span class="cl">&gt; SDIFF bikes:racing:france bikes:racing:usa bikes:racing:italy </span></span><span class="line hl"><span class="cl">(empty array) </span></span><span class="line hl"><span class="cl">&gt; SDIFF bikes:racing:france bikes:racing:usa </span></span><span class="line hl"><span class="cl">1) "bike:3" </span></span><span class="line hl"><span class="cl">2) "bike:2" </span></span><span class="line hl"><span class="cl">&gt; SDIFF bikes:racing:usa bikes:racing:france </span></span><span class="line hl"><span class="cl">1) "bike:4"</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_sets_tutorial-stepmultisets')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_sets_tutorial-stepmultisets" name="sets_tutorial-stepmultisets" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_sets_tutorial-stepmultisets" title="Open example"> Python </label> <div aria-labelledby="tab-sets_tutorial-stepmultisets" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_sets_tutorial-stepmultisets" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for Set doc pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/sets/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sismember</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sismember</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sinter</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:1'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">scard</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">smembers</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:1', 'bike:2', 'bike:3'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sismember</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">smismember</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1, 1, 0]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sdiff</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:2', 'bike:3'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:italy"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sinter</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bikes:racing:italy"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:1'}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sunion</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bikes:racing:italy"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:1', 'bike:2', 'bike:3', 'bike:4'}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sdiff</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bikes:racing:italy"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sdiff</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:4'}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sdiff</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:2', 'bike:3'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">srem</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res18</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">spop</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">smembers</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:2', 'bike:4', 'bike:5'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">srandmember</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res21</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:4</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_sets_tutorial-stepmultisets')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_sets_tutorial-stepmultisets" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_set.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_sets_tutorial-stepmultisets" name="sets_tutorial-stepmultisets" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_sets_tutorial-stepmultisets" title="Open example"> Node.js </label> <div aria-labelledby="tab-sets_tutorial-stepmultisets" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_sets_tutorial-stepmultisets" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">createClient</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sIsMember</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sIsMember</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sInter</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; {'bike:1'} </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sCard</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sMembers</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:1', 'bike:2', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sIsMember</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">smIsMember</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [true, true, false] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res13</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sDiff</span><span class="p">([</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [ 'bike:2', 'bike:3' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line hl"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line hl"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:italy'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sInter</span><span class="p">(</span> </span></span><span class="line hl"><span class="cl"> <span class="p">[</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bikes:racing:italy'</span><span class="p">]</span> </span></span><span class="line hl"><span class="cl"><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:1'] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res15</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sUnion</span><span class="p">(</span> </span></span><span class="line hl"><span class="cl"> <span class="p">[</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bikes:racing:italy'</span><span class="p">]</span> </span></span><span class="line hl"><span class="cl"><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:1', 'bike:2', 'bike:3', 'bike:4'] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res16</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sDiff</span><span class="p">([</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bikes:racing:italy'</span><span class="p">])</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res17</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sDiff</span><span class="p">([</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bikes:racing:france'</span><span class="p">])</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:4'] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res18</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sDiff</span><span class="p">([</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">])</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:2', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">debugger</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sRem</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sPop</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:3 or other random value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res21</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sMembers</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:2', 'bike:4', 'bike:5']; depends on previous result </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res22</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sRandMember</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:4 or other random value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_sets_tutorial-stepmultisets')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_sets_tutorial-stepmultisets" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-set.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_sets_tutorial-stepmultisets" name="sets_tutorial-stepmultisets" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_sets_tutorial-stepmultisets" title="Open example"> Java </label> <div aria-labelledby="tab-sets_tutorial-stepmultisets" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_sets_tutorial-stepmultisets" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nn">io.redis.examples</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.junit.Test</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.List</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.Set</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.assertTrue</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.assertFalse</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.assertEquals</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">SetsExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sismember</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sismember</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sinter</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">scard</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">smembers</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1, bike:2, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sismember</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Boolean</span><span class="o">&gt;</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">smismember</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [true,true,false] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sdiff</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res13</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:italy"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sinter</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bikes:racing:italy"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res14</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sunion</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bikes:racing:italy"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res15</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1, bike:2, bike:3, bike:4] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res16</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sdiff</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bikes:racing:italy"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res16</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sdiff</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res17</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:4] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sdiff</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2, bike:3] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">srem</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">spop</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res20</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res21</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">smembers</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res21</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2, bike:4, bike:5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res22</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">srandmember</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res22</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:4 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">close</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_sets_tutorial-stepmultisets')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_sets_tutorial-stepmultisets" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/SetsExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_sets_tutorial-stepmultisets" name="sets_tutorial-stepmultisets" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_sets_tutorial-stepmultisets" title="Open example"> Go </label> <div aria-labelledby="tab-sets_tutorial-stepmultisets" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_sets_tutorial-stepmultisets" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_sadd</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_sismember</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SIsMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SIsMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_sinter</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SInter</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_scard</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SCard</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_saddsmembers</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SMembers</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1 bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_smismember</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SIsMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SMIsMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [true true false] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_sdiff</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SDiff</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_multisets</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:italy"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SInter</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bikes:racing:italy"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SUnion</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bikes:racing:italy"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1 bike:2 bike:3 bike:4] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SDiff</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bikes:racing:italy"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SDiff</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:4] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SDiff</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_srem</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SRem</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;random element&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SMembers</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;remaining elements&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res22</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SRandMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;random element&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Testable examples not available because the test output </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// is not deterministic. </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_sets_tutorial-stepmultisets')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_sets_tutorial-stepmultisets" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/sets_example_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_sets_tutorial-stepmultisets" name="sets_tutorial-stepmultisets" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_sets_tutorial-stepmultisets" title="Open example"> C# </label> <div aria-labelledby="tab-sets_tutorial-stepmultisets" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_sets_tutorial-stepmultisets" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">System.Data.Common</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Tests</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">StackExchange.Redis</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">SetsExample</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res3</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res4</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sadd' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetContains</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res5</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetContains</span><span class="p">(</span><span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sismember' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Intersect</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res9</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sinter' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetLength</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'scard' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetMembers</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res13</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:3, bike:2, bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sadd_smembers' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetContains</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res14</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span><span class="p">[]</span> <span class="n">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetContains</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res15</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; True, True, False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'smismember' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Difference</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res18</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:2, bike:3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sdiff' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res21</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:italy"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res22</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Intersect</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="s">"{bikes:racing}:italy"</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res22</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:1</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res23</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Union</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="s">"{bikes:racing}:italy"</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res23</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:1, bike:2, bike:3, bike:4</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res24</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Difference</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="s">"{bikes:racing}:italy"</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res24</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; &lt;empty set&gt;</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res25</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Difference</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="s">"{bikes:racing}:france"</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res25</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:4</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res26</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Difference</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res26</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:2, bike:3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'multisets' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res27</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res28</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetRemove</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res28</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res29</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetPop</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res29</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; bike:3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res30</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetMembers</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res30</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:2, bike:4, bike:5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res31</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetRandomMember</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res31</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; bike:4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'srem' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_sets_tutorial-stepmultisets')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_sets_tutorial-stepmultisets" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/SetsTutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <p> You'll note that the <a href="/docs/latest/commands/sdiff/"> <code> SDIFF </code> </a> command returns an empty array when the difference between all sets is empty. You'll also note that the order of sets passed to <a href="/docs/latest/commands/sdiff/"> <code> SDIFF </code> </a> matters, since the difference is not commutative. </p> <p> When you want to remove items from a set, you can use the <a href="/docs/latest/commands/srem/"> <code> SREM </code> </a> command to remove one or more items from a set, or you can use the <a href="/docs/latest/commands/spop/"> <code> SPOP </code> </a> command to remove a random item from a set. You can also <em> return </em> a random item from a set without removing it using the <a href="/docs/latest/commands/srandmember/"> <code> SRANDMEMBER </code> </a> command: </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="sets_tutorial-stepsrem"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_sets_tutorial-stepsrem" name="sets_tutorial-stepsrem" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_sets_tutorial-stepsrem" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-sets_tutorial-stepsrem" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_sets_tutorial-stepsrem" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; SADD bikes:racing:france bike:1 bike:2 bike:3 bike:4 bike:5 </span></span><span class="line hl"><span class="cl">(integer) 5 </span></span><span class="line hl"><span class="cl">&gt; SREM bikes:racing:france bike:1 </span></span><span class="line hl"><span class="cl">(integer) 1 </span></span><span class="line hl"><span class="cl">&gt; SPOP bikes:racing:france </span></span><span class="line hl"><span class="cl">"bike:3" </span></span><span class="line hl"><span class="cl">&gt; SMEMBERS bikes:racing:france </span></span><span class="line hl"><span class="cl">1) "bike:2" </span></span><span class="line hl"><span class="cl">2) "bike:4" </span></span><span class="line hl"><span class="cl">3) "bike:5" </span></span><span class="line hl"><span class="cl">&gt; SRANDMEMBER bikes:racing:france </span></span><span class="line hl"><span class="cl">"bike:2"</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_sets_tutorial-stepsrem')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_sets_tutorial-stepsrem" name="sets_tutorial-stepsrem" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_sets_tutorial-stepsrem" title="Open example"> Python </label> <div aria-labelledby="tab-sets_tutorial-stepsrem" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_sets_tutorial-stepsrem" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for Set doc pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/sets/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sismember</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sismember</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sinter</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:1'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">scard</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">smembers</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:1', 'bike:2', 'bike:3'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sismember</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">smismember</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1, 1, 0]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sdiff</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:2', 'bike:3'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:italy"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sinter</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bikes:racing:italy"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:1'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sunion</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bikes:racing:italy"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:1', 'bike:2', 'bike:3', 'bike:4'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sdiff</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bikes:racing:italy"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sdiff</span><span class="p">(</span><span class="s2">"bikes:racing:usa"</span><span class="p">,</span> <span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:4'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">sdiff</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bikes:racing:usa"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:2', 'bike:3'}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">sadd</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"bike:4"</span><span class="p">,</span> <span class="s2">"bike:5"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">srem</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">,</span> <span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res18</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 1</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">spop</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:3</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">smembers</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; {'bike:2', 'bike:4', 'bike:5'}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">srandmember</span><span class="p">(</span><span class="s2">"bikes:racing:france"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res21</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; bike:4</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_sets_tutorial-stepsrem')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_sets_tutorial-stepsrem" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_set.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_sets_tutorial-stepsrem" name="sets_tutorial-stepsrem" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_sets_tutorial-stepsrem" title="Open example"> Node.js </label> <div aria-labelledby="tab-sets_tutorial-stepsrem" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_sets_tutorial-stepsrem" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">createClient</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sIsMember</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sIsMember</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sInter</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; {'bike:1'} </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sCard</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sMembers</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:1', 'bike:2', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sIsMember</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">smIsMember</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [true, true, false] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res13</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sDiff</span><span class="p">([</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [ 'bike:2', 'bike:3' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:italy'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sInter</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="p">[</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bikes:racing:italy'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:1'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res15</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sUnion</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="p">[</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bikes:racing:italy'</span><span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:1', 'bike:2', 'bike:3', 'bike:4'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res16</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sDiff</span><span class="p">([</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bikes:racing:italy'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res17</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sDiff</span><span class="p">([</span><span class="s1">'bikes:racing:usa'</span><span class="p">,</span> <span class="s1">'bikes:racing:france'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:4'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res18</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sDiff</span><span class="p">([</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bikes:racing:usa'</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:2', 'bike:3'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">debugger</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sAdd</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'bike:2'</span><span class="p">,</span> <span class="s1">'bike:3'</span><span class="p">,</span> <span class="s1">'bike:4'</span><span class="p">,</span> <span class="s1">'bike:5'</span><span class="p">])</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sRem</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">,</span> <span class="s1">'bike:1'</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sPop</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:3 or other random value </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res21</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sMembers</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ['bike:2', 'bike:4', 'bike:5']; depends on previous result </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res22</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">sRandMember</span><span class="p">(</span><span class="s1">'bikes:racing:france'</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; bike:4 or other random value </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_sets_tutorial-stepsrem')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_sets_tutorial-stepsrem" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-set.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_sets_tutorial-stepsrem" name="sets_tutorial-stepsrem" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_sets_tutorial-stepsrem" title="Open example"> Java </label> <div aria-labelledby="tab-sets_tutorial-stepsrem" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_sets_tutorial-stepsrem" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nn">io.redis.examples</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.junit.Test</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.List</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.Set</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.assertTrue</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.assertFalse</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import static</span> <span class="nn">org.junit.Assert.assertEquals</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">SetsExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sismember</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sismember</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sinter</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">scard</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">smembers</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1, bike:2, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sismember</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Boolean</span><span class="o">&gt;</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">smismember</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [true,true,false] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sdiff</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res13</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:italy"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sinter</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bikes:racing:italy"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res14</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sunion</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bikes:racing:italy"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res15</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:1, bike:2, bike:3, bike:4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res16</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sdiff</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bikes:racing:italy"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res16</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sdiff</span><span class="o">(</span><span class="s">"bikes:racing:usa"</span><span class="o">,</span> <span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res17</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">sdiff</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bikes:racing:usa"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2, bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">sadd</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"bike:4"</span><span class="o">,</span> <span class="s">"bike:5"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">srem</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">,</span> <span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">spop</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res20</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:3 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">Set</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">res21</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">smembers</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res21</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [bike:2, bike:4, bike:5] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">res22</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">srandmember</span><span class="o">(</span><span class="s">"bikes:racing:france"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res22</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bike:4 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">close</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_sets_tutorial-stepsrem')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_sets_tutorial-stepsrem" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/SetsExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_sets_tutorial-stepsrem" name="sets_tutorial-stepsrem" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_sets_tutorial-stepsrem" title="Open example"> Go </label> <div aria-labelledby="tab-sets_tutorial-stepsrem" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_sets_tutorial-stepsrem" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_sadd</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 0 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 2 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_sismember</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SIsMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SIsMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; false </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_sinter</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SInter</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_scard</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SCard</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_saddsmembers</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SMembers</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1 bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_smismember</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SIsMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; true </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SMIsMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [true true false] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_sdiff</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SDiff</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_multisets</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:italy"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SInter</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bikes:racing:italy"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SUnion</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bikes:racing:italy"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:1 bike:2 bike:3 bike:4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SDiff</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bikes:racing:italy"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SDiff</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SDiff</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bikes:racing:usa"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [bike:2 bike:3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_srem</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SRem</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;random element&gt; </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SMembers</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;remaining elements&gt; </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res22</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SRandMember</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:racing:france"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; &lt;random element&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Testable examples not available because the test output </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// is not deterministic. </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_sets_tutorial-stepsrem')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_sets_tutorial-stepsrem" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/sets_example_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_sets_tutorial-stepsrem" name="sets_tutorial-stepsrem" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_sets_tutorial-stepsrem" title="Open example"> C# </label> <div aria-labelledby="tab-sets_tutorial-stepsrem" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_sets_tutorial-stepsrem" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">System.Data.Common</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Tests</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">StackExchange.Redis</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">SetsExample</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res3</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res4</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sadd' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetContains</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res5</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetContains</span><span class="p">(</span><span class="s">"bikes:racing:usa"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sismember' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Intersect</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res9</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sinter' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetLength</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'scard' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetMembers</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res13</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:3, bike:2, bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sadd_smembers' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetContains</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res14</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span><span class="p">[]</span> <span class="n">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetContains</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res15</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; True, True, False</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'smismember' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Difference</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res18</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:2, bike:3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'sdiff' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res21</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"{bikes:racing}:italy"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res22</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Intersect</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="s">"{bikes:racing}:italy"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res22</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res23</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Union</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="s">"{bikes:racing}:italy"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res23</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:1, bike:2, bike:3, bike:4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res24</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Difference</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="s">"{bikes:racing}:italy"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res24</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; &lt;empty set&gt;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res25</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Difference</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:usa"</span><span class="p">,</span> <span class="s">"{bikes:racing}:france"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res25</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res26</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetCombine</span><span class="p">(</span><span class="n">SetOperation</span><span class="p">.</span><span class="n">Difference</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"{bikes:racing}:france"</span><span class="p">,</span> <span class="s">"{bikes:racing}:usa"</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res26</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:2, bike:3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'multisets' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res27</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetAdd</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"bike:4"</span><span class="p">,</span> <span class="s">"bike:5"</span> <span class="p">});</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">bool</span> <span class="n">res28</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetRemove</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res28</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res29</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetPop</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res29</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; bike:3</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res30</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetMembers</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res30</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; bike:2, bike:4, bike:5</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res31</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SetRandomMember</span><span class="p">(</span><span class="s">"bikes:racing:france"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res31</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; bike:4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'srem' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_sets_tutorial-stepsrem')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_sets_tutorial-stepsrem" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/SetsTutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <h2 id="limits"> Limits </h2> <p> The max size of a Redis set is 2^32 - 1 (4,294,967,295) members. </p> <h2 id="performance"> Performance </h2> <p> Most set operations, including adding, removing, and checking whether an item is a set member, are O(1). This means that they're highly efficient. However, for large sets with hundreds of thousands of members or more, you should exercise caution when running the <a href="/docs/latest/commands/smembers/"> <code> SMEMBERS </code> </a> command. This command is O(n) and returns the entire set in a single response. As an alternative, consider the <a href="/docs/latest/commands/sscan/"> <code> SSCAN </code> </a> , which lets you retrieve all members of a set iteratively. </p> <h2 id="alternatives"> Alternatives </h2> <p> Sets membership checks on large datasets (or on streaming data) can use a lot of memory. If you're concerned about memory usage and don't need perfect precision, consider a <a href="/docs/latest/develop/data-types/probabilistic/bloom-filter/"> Bloom filter or Cuckoo filter </a> as an alternative to a set. </p> <p> Redis sets are frequently used as a kind of index. If you need to index and query your data, consider the <a href="/docs/latest/develop/data-types/json/"> JSON </a> data type and the <a href="/docs/latest/develop/interact/search-and-query/"> Redis Query Engine </a> features. </p> <h2 id="learn-more"> Learn more </h2> <ul> <li> <a href="https://www.youtube.com/watch?v=PKdCppSNTGQ"> Redis Sets Explained </a> and <a href="https://www.youtube.com/watch?v=aRw5ME_5kMY"> Redis Sets Elaborated </a> are two short but thorough video explainers covering Redis sets. </li> <li> <a href="https://university.redis.com/courses/ru101/"> Redis University's RU101 </a> explores Redis sets in detail. </li> </ul> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/develop/data-types/sets/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/integrate/redis-data-integration/reference/cli/redis-di-delete-context/.html
<section class="prose w-full py-12"> <h1> redis-di delete-context </h1> <p class="text-lg -mt-5 mb-10"> Deletes a context </p> <h2 id="usage"> Usage </h2> <pre tabindex="0"><code>Usage: redis-di delete-context [OPTIONS] CONTEXT_NAME </code></pre> <h2 id="options"> Options </h2> <ul> <li> <p> <code> log_level </code> : </p> <ul> <li> Type: Choice(['DEBUG', 'INFO', 'WARN', 'ERROR', 'CRITICAL']) </li> <li> Default: <code> info </code> </li> <li> Usage: <code> --log-level -l </code> </li> </ul> </li> <li> <p> <code> context_name </code> (REQUIRED): </p> <ul> <li> Type: STRING </li> <li> Default: <code> none </code> </li> <li> Usage: <code> context-name </code> </li> </ul> </li> <li> <p> <code> force </code> : </p> <ul> <li> Type: BOOL </li> <li> Default: <code> false </code> </li> <li> Usage: <code> --force -f </code> </li> </ul> <p> Force operation. skips verification prompts </p> </li> <li> <p> <code> help </code> : </p> <ul> <li> Type: BOOL </li> <li> Default: <code> false </code> </li> <li> Usage: <code> --help </code> </li> </ul> <p> Show this message and exit. </p> </li> </ul> <h2 id="cli-help"> CLI help </h2> <pre tabindex="0"><code>Usage: redis-di delete-context [OPTIONS] CONTEXT_NAME Deletes a context Options: -l, --log-level [DEBUG|INFO|WARN|ERROR|CRITICAL] [default: INFO] -f, --force Force operation. skips verification prompts --help Show this message and exit. </code></pre> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/integrate/redis-data-integration/reference/cli/redis-di-delete-context/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/oss_and_stack/management/optimization/benchmarks/.html
<section class="prose w-full py-12 max-w-none"> <h1> Redis benchmark </h1> <p class="text-lg -mt-5 mb-10"> Use the redis-benchmark utility on a Redis server </p> <h2 id="how-fast-is-redis"> How fast is Redis? </h2> <p> Redis includes the <code> redis-benchmark </code> utility that simulates running commands done by N clients at the same time sending M total queries (it is similar to the Apache's <code> ab </code> utility). Below you'll find the full output of a benchmark executed against a Linux box. </p> <p> The following options are supported: </p> <pre><code>Usage: redis-benchmark [-h &lt;host&gt;] [-p &lt;port&gt;] [-c &lt;clients&gt;] [-n &lt;requests]&gt; [-k &lt;boolean&gt;] -h &lt;hostname&gt; Server hostname (default 127.0.0.1) -p &lt;port&gt; Server port (default 6379) -s &lt;socket&gt; Server socket (overrides host and port) -a &lt;password&gt; Password for Redis Auth --user &lt;username&gt; Used to send ACL style 'AUTH username pass'. Needs -a. -c &lt;clients&gt; Number of parallel connections (default 50) -n &lt;requests&gt; Total number of requests (default 100000) -d &lt;size&gt; Data size of SET/GET value in bytes (default 3) --dbnum &lt;db&gt; SELECT the specified db number (default 0) --threads &lt;num&gt; Enable multi-thread mode. --cluster Enable cluster mode. --enable-tracking Send CLIENT TRACKING on before starting benchmark. -k &lt;boolean&gt; 1=keep alive 0=reconnect (default 1) -r &lt;keyspacelen&gt; Use random keys for SET/GET/INCR, random values for SADD, random members and scores for ZADD. Using this option the benchmark will expand the string __rand_int__ inside an argument with a 12 digits number in the specified range from 0 to keyspacelen-1. The substitution changes every time a command is executed. Default tests use this to hit random keys in the specified range. -P &lt;numreq&gt; Pipeline &lt;numreq&gt; requests. Default 1 (no pipeline). -e If server replies with errors, show them on stdout. (No more than 1 error per second is displayed.) -q Quiet. Just show query/sec values --precision Number of decimal places to display in latency output (default 0) --csv Output in CSV format -l Loop. Run the tests forever -t &lt;tests&gt; Only run the comma separated list of tests. The test names are the same as the ones produced as output. -I Idle mode. Just open N idle connections and wait. --help Output this help and exit. --version Output version and exit. </code></pre> <p> You need to have a running Redis instance before launching the benchmark. A typical example would be: </p> <pre><code>redis-benchmark -q -n 100000 </code></pre> <p> Using this tool is quite easy, and you can also write your own benchmark, but as with any benchmarking activity, there are some pitfalls to avoid. </p> <h2 id="running-only-a-subset-of-the-tests"> Running only a subset of the tests </h2> <p> You don't need to run all the default tests every time you execute redis-benchmark. The simplest thing to select only a subset of tests is to use the <code> -t </code> option like in the following example: </p> <pre><code>$ redis-benchmark -t set,lpush -n 100000 -q SET: 180180.17 requests per second, p50=0.143 msec LPUSH: 188323.91 requests per second, p50=0.135 msec </code></pre> <p> In the above example we asked to just run test the SET and LPUSH commands, in quiet mode (see the <code> -q </code> switch). </p> <p> It is also possible to specify the command to benchmark directly like in the following example: </p> <pre><code>$ redis-benchmark -n 100000 -q script load "redis.call('set','foo','bar')" script load redis.call('set','foo','bar'): 69881.20 requests per second </code></pre> <h2 id="selecting-the-size-of-the-key-space"> Selecting the size of the key space </h2> <p> By default the benchmark runs against a single key. In Redis the difference between such a synthetic benchmark and a real one is not huge since it is an in-memory system, however it is possible to stress cache misses and in general to simulate a more real-world work load by using a large key space. </p> <p> This is obtained by using the <code> -r </code> switch. For instance if I want to run one million SET operations, using a random key for every operation out of 100k possible keys, I'll use the following command line: </p> <pre><code>$ redis-cli flushall OK $ redis-benchmark -t set -r 100000 -n 1000000 ====== SET ====== 1000000 requests completed in 13.86 seconds 50 parallel clients 3 bytes payload keep alive: 1 99.76% `&lt;=` 1 milliseconds 99.98% `&lt;=` 2 milliseconds 100.00% `&lt;=` 3 milliseconds 100.00% `&lt;=` 3 milliseconds 72144.87 requests per second $ redis-cli dbsize (integer) 99993 </code></pre> <h2 id="using-pipelining"> Using pipelining </h2> <p> By default every client (the benchmark simulates 50 clients if not otherwise specified with <code> -c </code> ) sends the next command only when the reply of the previous command is received, this means that the server will likely need a read call in order to read each command from every client. Also RTT is paid as well. </p> <p> Redis supports <a href="/topics/pipelining"> pipelining </a> , so it is possible to send multiple commands at once, a feature often exploited by real world applications. Redis pipelining is able to dramatically improve the number of operations per second a server is able do deliver. </p> <p> This is an example of running the benchmark in a MacBook Air 11" using a pipelining of 16 commands: </p> <pre><code>$ redis-benchmark -n 1000000 -t set,get -P 16 -q SET: 1536098.25 requests per second, p50=0.479 msec GET: 1811594.25 requests per second, p50=0.391 msec </code></pre> <p> Using pipelining results in a significant increase in performance. </p> <h2 id="pitfalls-and-misconceptions"> Pitfalls and misconceptions </h2> <p> The first point is obvious: the golden rule of a useful benchmark is to only compare apples and apples. Different versions of Redis can be compared on the same workload for instance. Or the same version of Redis, but with different options. If you plan to compare Redis to something else, then it is important to evaluate the functional and technical differences, and take them in account. </p> <ul> <li> Redis is a server: all commands involve network or IPC round trips. It is meaningless to compare it to embedded data stores such as SQLite, Berkeley DB, Tokyo/Kyoto Cabinet, etc ... because the cost of most operations is primarily in network/protocol management. </li> <li> Redis commands return an acknowledgment for all usual commands. Some other data stores do not. Comparing Redis to stores involving one-way queries is only mildly useful. </li> <li> Naively iterating on synchronous Redis commands does not benchmark Redis itself, but rather measure your network (or IPC) latency and the client library intrinsic latency. To really test Redis, you need multiple connections (like redis-benchmark) and/or to use pipelining to aggregate several commands and/or multiple threads or processes. </li> <li> Redis is an in-memory data store with some optional persistence options. If you plan to compare it to transactional servers (MySQL, PostgreSQL, etc ...), then you should consider activating AOF and decide on a suitable fsync policy. </li> <li> Redis is, mostly, a single-threaded server from the POV of commands execution (actually modern versions of Redis use threads for different things). It is not designed to benefit from multiple CPU cores. People are supposed to launch several Redis instances to scale out on several cores if needed. It is not really fair to compare one single Redis instance to a multi-threaded data store. </li> </ul> <p> A common misconception is that redis-benchmark is designed to make Redis performances look stellar, the throughput achieved by redis-benchmark being somewhat artificial, and not achievable by a real application. This is actually not true. </p> <p> The <code> redis-benchmark </code> program is a quick and useful way to get some figures and evaluate the performance of a Redis instance on a given hardware. However, by default, it does not represent the maximum throughput a Redis instance can sustain. Actually, by using pipelining and a fast client (hiredis), it is fairly easy to write a program generating more throughput than redis-benchmark. The default behavior of redis-benchmark is to achieve throughput by exploiting concurrency only (i.e. it creates several connections to the server). It does not use pipelining or any parallelism at all (one pending query per connection at most, and no multi-threading), if not explicitly enabled via the <code> -P </code> parameter. So in some way using <code> redis-benchmark </code> and, triggering, for example, a <code> BGSAVE </code> operation in the background at the same time, will provide the user with numbers more near to the <em> worst case </em> than to the best case. </p> <p> To run a benchmark using pipelining mode (and achieve higher throughput), you need to explicitly use the -P option. Please note that it is still a realistic behavior since a lot of Redis based applications actively use pipelining to improve performance. However you should use a pipeline size that is more or less the average pipeline length you'll be able to use in your application in order to get realistic numbers. </p> <p> Finally, the benchmark should apply the same operations, and work in the same way with the multiple data stores you want to compare. It is absolutely pointless to compare the result of redis-benchmark to the result of another benchmark program and extrapolate. </p> <p> For instance, Redis and memcached in single-threaded mode can be compared on GET/SET operations. Both are in-memory data stores, working mostly in the same way at the protocol level. Provided their respective benchmark application is aggregating queries in the same way (pipelining) and use a similar number of connections, the comparison is actually meaningful. </p> <p> This perfect example is illustrated by the dialog between Redis (antirez) and memcached (dormando) developers. </p> <p> <a href="http://antirez.com/post/redis-memcached-benchmark.html"> antirez 1 - On Redis, Memcached, Speed, Benchmarks and The Toilet </a> </p> <p> <a href="http://dormando.livejournal.com/525147.html"> dormando - Redis VS Memcached (slightly better bench) </a> </p> <p> <a href="http://antirez.com/post/update-on-memcached-redis-benchmark.html"> antirez 2 - An update on the Memcached/Redis benchmark </a> </p> <p> You can see that in the end, the difference between the two solutions is not so staggering, once all technical aspects are considered. Please note both Redis and memcached have been optimized further after these benchmarks. </p> <p> Finally, when very efficient servers are benchmarked (and stores like Redis or memcached definitely fall in this category), it may be difficult to saturate the server. Sometimes, the performance bottleneck is on client side, and not server-side. In that case, the client (i.e. the benchmark program itself) must be fixed, or perhaps scaled out, in order to reach the maximum throughput. </p> <h2 id="factors-impacting-redis-performance"> Factors impacting Redis performance </h2> <p> There are multiple factors having direct consequences on Redis performance. We mention them here, since they can alter the result of any benchmarks. Please note however, that a typical Redis instance running on a low end, untuned box usually provides good enough performance for most applications. </p> <ul> <li> Network bandwidth and latency usually have a direct impact on the performance. It is a good practice to use the ping program to quickly check the latency between the client and server hosts is normal before launching the benchmark. Regarding the bandwidth, it is generally useful to estimate the throughput in Gbit/s and compare it to the theoretical bandwidth of the network. For instance a benchmark setting 4 KB strings in Redis at 100000 q/s, would actually consume 3.2 Gbit/s of bandwidth and probably fit within a 10 Gbit/s link, but not a 1 Gbit/s one. In many real world scenarios, Redis throughput is limited by the network well before being limited by the CPU. To consolidate several high-throughput Redis instances on a single server, it worth considering putting a 10 Gbit/s NIC or multiple 1 Gbit/s NICs with TCP/IP bonding. </li> <li> CPU is another very important factor. Being single-threaded, Redis favors fast CPUs with large caches and not many cores. At this game, Intel CPUs are currently the winners. It is not uncommon to get only half the performance on an AMD Opteron CPU compared to similar Nehalem EP/Westmere EP/Sandy Bridge Intel CPUs with Redis. When client and server run on the same box, the CPU is the limiting factor with redis-benchmark. </li> <li> Speed of RAM and memory bandwidth seem less critical for global performance especially for small objects. For large objects (&gt;10 KB), it may become noticeable though. Usually, it is not really cost-effective to buy expensive fast memory modules to optimize Redis. </li> <li> Redis runs slower on a VM compared to running without virtualization using the same hardware. If you have the chance to run Redis on a physical machine this is preferred. However this does not mean that Redis is slow in virtualized environments, the delivered performances are still very good and most of the serious performance issues you may incur in virtualized environments are due to over-provisioning, non-local disks with high latency, or old hypervisor software that have slow <code> fork </code> syscall implementation. </li> <li> When the server and client benchmark programs run on the same box, both the TCP/IP loopback and unix domain sockets can be used. Depending on the platform, unix domain sockets can achieve around 50% more throughput than the TCP/IP loopback (on Linux for instance). The default behavior of redis-benchmark is to use the TCP/IP loopback. </li> <li> The performance benefit of unix domain sockets compared to TCP/IP loopback tends to decrease when pipelining is heavily used (i.e. long pipelines). </li> <li> When an ethernet network is used to access Redis, aggregating commands using pipelining is especially efficient when the size of the data is kept under the ethernet packet size (about 1500 bytes). Actually, processing 10 bytes, 100 bytes, or 1000 bytes queries almost result in the same throughput. See the graph below. </li> </ul> <p> <img alt="Data size impact" src="https://github.com/dspezia/redis-doc/raw/client_command/topics/Data_size.png"/> </p> <ul> <li> On multi CPU sockets servers, Redis performance becomes dependent on the NUMA configuration and process location. The most visible effect is that redis-benchmark results seem non-deterministic because client and server processes are distributed randomly on the cores. To get deterministic results, it is required to use process placement tools (on Linux: taskset or numactl). The most efficient combination is always to put the client and server on two different cores of the same CPU to benefit from the L3 cache. Here are some results of 4 KB SET benchmark for 3 server CPUs (AMD Istanbul, Intel Nehalem EX, and Intel Westmere) with different relative placements. Please note this benchmark is not meant to compare CPU models between themselves (CPUs exact model and frequency are therefore not disclosed). </li> </ul> <p> <img alt="NUMA chart" src="https://github.com/dspezia/redis-doc/raw/6374a07f93e867353e5e946c1e39a573dfc83f6c/topics/NUMA_chart.gif"/> </p> <ul> <li> With high-end configurations, the number of client connections is also an important factor. Being based on epoll/kqueue, the Redis event loop is quite scalable. Redis has already been benchmarked at more than 60000 connections, and was still able to sustain 50000 q/s in these conditions. As a rule of thumb, an instance with 30000 connections can only process half the throughput achievable with 100 connections. Here is an example showing the throughput of a Redis instance per number of connections: </li> </ul> <p> <img alt="connections chart" src="https://github.com/dspezia/redis-doc/raw/system_info/topics/Connections_chart.png"/> </p> <ul> <li> With high-end configurations, it is possible to achieve higher throughput by tuning the NIC(s) configuration and associated interruptions. Best throughput is achieved by setting an affinity between Rx/Tx NIC queues and CPU cores, and activating RPS (Receive Packet Steering) support. More information in this <a href="https://groups.google.com/forum/#!msg/redis-db/gUhc19gnYgc/BruTPCOroiMJ"> thread </a> . Jumbo frames may also provide a performance boost when large objects are used. </li> <li> Depending on the platform, Redis can be compiled against different memory allocators (libc malloc, jemalloc, tcmalloc), which may have different behaviors in term of raw speed, internal and external fragmentation. If you did not compile Redis yourself, you can use the INFO command to check the <code> mem_allocator </code> field. Please note most benchmarks do not run long enough to generate significant external fragmentation (contrary to production Redis instances). </li> </ul> <h2 id="other-things-to-consider"> Other things to consider </h2> <p> One important goal of any benchmark is to get reproducible results, so they can be compared to the results of other tests. </p> <ul> <li> A good practice is to try to run tests on isolated hardware as much as possible. If it is not possible, then the system must be monitored to check the benchmark is not impacted by some external activity. </li> <li> Some configurations (desktops and laptops for sure, some servers as well) have a variable CPU core frequency mechanism. The policy controlling this mechanism can be set at the OS level. Some CPU models are more aggressive than others at adapting the frequency of the CPU cores to the workload. To get reproducible results, it is better to set the highest possible fixed frequency for all the CPU cores involved in the benchmark. </li> <li> An important point is to size the system accordingly to the benchmark. The system must have enough RAM and must not swap. On Linux, do not forget to set the <code> overcommit_memory </code> parameter correctly. Please note 32 and 64 bit Redis instances do not have the same memory footprint. </li> <li> If you plan to use RDB or AOF for your benchmark, please check there is no other I/O activity in the system. Avoid putting RDB or AOF files on NAS or NFS shares, or on any other devices impacting your network bandwidth and/or latency (for instance, EBS on Amazon EC2). </li> <li> Set Redis logging level (loglevel parameter) to warning or notice. Avoid putting the generated log file on a remote filesystem. </li> <li> Avoid using monitoring tools which can alter the result of the benchmark. For instance using INFO at regular interval to gather statistics is probably fine, but MONITOR will impact the measured performance significantly. </li> </ul> <h2 id="benchmark-results-on-bare-metal-servers-across-different-redis-versions"> Benchmark results on bare-metal servers across different Redis versions </h2> <p> It is critically important that Redis performance is retained or improved seamlessly on every released version. </p> <p> To assess it, we've conducted benchmarks on the released versions of Redis (starting on v2.6.0) using <code> redis-benchmark </code> on a series of command types over a standalone redis-server, repeating the same benchmark multiple times, ensuring its statistical significance, and measuring the run-to-run variance. </p> <p> The used hardware platform was a stable bare-metal HPE ProLiant DL380 Gen10 Server, with one Intel(R) Xeon(R) Gold 6230 CPU @ 2.10GHz, disabling Intel HT Technology, disabling CPU Frequency scaling, with all configurable BIOS and CPU system settings set to performance. </p> <p> The box was running Ubuntu 18.04 Linux release 4.15.0-123, and Redis was compiled with gcc 7.5.0. The used benchmark client ( <code> redis-benchmark </code> ) was kept stable across all tests, with version <code> redis-benchmark 6.2.0 (git:445aa844) </code> . Both the redis-server and redis-benchmark processes were pinned to specific physical cores. </p> <p> The following benchmark options were used across tests: </p> <ul> <li> The tests were done with 50 simultaneous clients performing 5 million requests. </li> <li> Tests were executed using the loopback interface. </li> <li> Tests were executed without pipelining. </li> <li> The used payload size was 256 Bytes. </li> <li> For each redis-benchmark process, 2 threads were used to ensure that the benchmark client was not the bottleneck. </li> <li> Strings, Hashes, Sets, and Sorted Sets data types were benchmarked. </li> </ul> <p> Below we present the obtained results, broken by data type. </p> <p> <img alt="Strings performance over versions" src="./performance-strings.png"/> </p> <p> <img alt="Hashes performance over versions" src="./performance-hashes.png"/> </p> <p> <img alt="Sets performance over versions" src="./performance-sets.png"/> </p> <p> <img alt="Sorted sets performance over versions" src="./performance-sorted-sets.png"/> </p> <h2 id="other-redis-benchmarking-tools"> Other Redis benchmarking tools </h2> <p> There are several third-party tools that can be used for benchmarking Redis. Refer to each tool's documentation for more information about its goals and capabilities. </p> <ul> <li> <a href="https://github.com/redislabs/memtier_benchmark"> memtier_benchmark </a> from <a href="https://twitter.com/RedisLabs"> Redis Labs </a> is a NoSQL Redis and Memcache traffic generation and benchmarking tool. </li> <li> <a href="https://github.com/twitter/rpc-perf"> rpc-perf </a> from <a href="https://twitter.com/twitter"> Twitter </a> is a tool for benchmarking RPC services that supports Redis and Memcache. </li> <li> <a href="https://github.com/brianfrankcooper/YCSB"> YCSB </a> from <a href="https://twitter.com/Yahoo"> Yahoo @Yahoo </a> is a benchmarking framework with clients to many databases, including Redis. </li> </ul> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/oss_and_stack/management/optimization/benchmarks/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/json.type.html
<section class="prose w-full py-12"> <h1 class="command-name"> JSON.TYPE </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">JSON.TYPE key [path]</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available in: </dt> <dd class="m-0"> <a href="/docs/stack"> Redis Stack </a> / <a href="/docs/data-types/json"> JSON 1.0.0 </a> </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(1) when path is evaluated to a single value, O(N) when path is evaluated to multiple values, where N is the size of the key </dd> </dl> <p> Report the type of JSON value at <code> path </code> </p> <p> <a href="#examples"> Examples </a> </p> <h2 id="required-arguments"> Required arguments </h2> <details open=""> <summary> <code> key </code> </summary> <p> is key to parse. </p> </details> <h2 id="optional-arguments"> Optional arguments </h2> <details open=""> <summary> <code> path </code> </summary> <p> is JSONPath to specify. Default is root <code> $ </code> . Returns null if the <code> key </code> or <code> path </code> do not exist. </p> </details> <h2 id="return"> Return </h2> <p> JSON.TYPE returns an array of string replies for each path, specified as the value's type. For more information about replies, see <a href="/docs/latest/develop/reference/protocol-spec/"> Redis serialization protocol specification </a> . </p> <h2 id="examples"> Examples </h2> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis&gt; JSON.SET doc $ <span class="s1">'{"a":2, "nested": {"a": true}, "foo": "bar"}'</span> </span></span><span class="line"><span class="cl">OK </span></span><span class="line"><span class="cl">redis&gt; JSON.TYPE doc $..foo </span></span><span class="line"><span class="cl">1<span class="o">)</span> <span class="s2">"string"</span> </span></span><span class="line"><span class="cl">redis&gt; JSON.TYPE doc $..a </span></span><span class="line"><span class="cl">1<span class="o">)</span> <span class="s2">"integer"</span> </span></span><span class="line"><span class="cl">2<span class="o">)</span> <span class="s2">"boolean"</span> </span></span><span class="line"><span class="cl">redis&gt; JSON.TYPE doc $..dummy </span></span><span class="line"><span class="cl"><span class="o">(</span>empty array<span class="o">)</span></span></span></code></pre> </div> <h2 id="see-also"> See also </h2> <p> <a href="/docs/latest/commands/json.set/"> <code> JSON.SET </code> </a> | <a href="/docs/latest/commands/json.arrlen/"> <code> JSON.ARRLEN </code> </a> </p> <h2 id="related-topics"> Related topics </h2> <ul> <li> <a href="/docs/latest/develop/data-types/json/"> RedisJSON </a> </li> <li> <a href="/docs/latest/develop/interact/search-and-query/indexing/"> Index and search JSON documents </a> </li> </ul> <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/json.type/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/groupsearch.html
<section class="prose w-full py-12"> <h1> Commands </h1> </section>
https://redis.io/docs/latest/operate/rs/7.4/references/rest-api/requests/bdbs/modules/config/.html
<section class="prose w-full py-12 max-w-none"> <h1> Database modules config requests </h1> <p class="text-lg -mt-5 mb-10"> Configure Redis module requests </p> <table> <thead> <tr> <th> Method </th> <th> Path </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="#post-bdb-modules-config"> POST </a> </td> <td> <code> /v1/bdbs/{uid}/modules/config </code> </td> <td> Configure module </td> </tr> </tbody> </table> <h2 id="post-bdb-modules-config"> Configure module </h2> <pre><code>POST /v1/bdbs/{string: uid}/modules/config </code></pre> <p> Use the module runtime configuration command (if defined) to configure new arguments for the module. </p> <h4 id="required-permissions"> Required permissions </h4> <table> <thead> <tr> <th> Permission name </th> </tr> </thead> <tbody> <tr> <td> <a href="/docs/latest/operate/rs/7.4/references/rest-api/permissions/#edit_bdb_module"> edit_bdb_module </a> </td> </tr> </tbody> </table> <h3 id="post-request"> Request </h3> <h4 id="example-http-request"> Example HTTP request </h4> <pre><code>POST /bdbs/1/modules/config </code></pre> <h4 id="example-json-body"> Example JSON body </h4> <div class="highlight"> <pre class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"modules"</span><span class="p">:</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"module_name"</span><span class="p">:</span> <span class="s2">"search"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"module_args"</span><span class="p">:</span> <span class="s2">"MINPREFIX 3 MAXEXPANSIONS 1000"</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <h4 id="request-headers"> Request headers </h4> <table> <thead> <tr> <th> Key </th> <th> Value </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> Host </td> <td> cnm.cluster.fqdn </td> <td> Domain name </td> </tr> <tr> <td> Accept </td> <td> application/json </td> <td> Accepted media type </td> </tr> </tbody> </table> <h4 id="request-body"> Request body </h4> <table> <thead> <tr> <th> Field </th> <th> Type </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> modules </td> <td> list of JSON objects </td> <td> List of modules (module_name) and their new configuration settings (module_args) </td> </tr> <tr> <td> module_name </td> <td> <code> search </code> <br/> <code> ReJSON </code> <br/> <code> graph </code> <br/> <code> timeseries </code> <br/> <code> bf </code> </td> <td> Module's name </td> </tr> <tr> <td> module_args </td> <td> string </td> <td> Module command line arguments (pattern does not allow special characters &amp;,&lt;,&gt;,”) </td> </tr> </tbody> </table> <h3 id="post-response"> Response </h3> <p> Returns a status code. If an error occurs, the response body may include an error code and message with more details. </p> <h3 id="post-error-codes"> Error codes </h3> <p> When errors are reported, the server may return a JSON object with <code> error_code </code> and <code> message </code> field that provide additional information. The following are possible <code> error_code </code> values: </p> <table> <thead> <tr> <th> Code </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> db_not_exist </td> <td> Database with given UID doesn't exist in cluster </td> </tr> <tr> <td> missing_field </td> <td> "module_name" or "module_args" are not defined in request </td> </tr> <tr> <td> invalid_schema </td> <td> JSON object received is not a dict object </td> </tr> <tr> <td> param_error </td> <td> "module_args" parameter was not parsed properly </td> </tr> <tr> <td> module_not_exist </td> <td> Module with given "module_name" does not exist for the database </td> </tr> </tbody> </table> <h3 id="post-status-codes"> Status codes </h3> <table> <thead> <tr> <th> Code </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1"> 200 OK </a> </td> <td> Success, module updated on bdb. </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5"> 404 Not Found </a> </td> <td> bdb not found. </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1"> 400 Bad Request </a> </td> <td> Bad or missing configuration parameters. </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.7"> 406 Not Acceptable </a> </td> <td> Module does not support runtime configuration of arguments. </td> </tr> </tbody> </table> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/references/rest-api/requests/bdbs/modules/config/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/references/cli-utilities/crdb-cli/crdb/add-instance/.html
<section class="prose w-full py-12 max-w-none"> <h1> crdb-cli crdb add-instance </h1> <p class="text-lg -mt-5 mb-10"> Adds a peer replica to an Active-Active database. </p> <p> Adds a peer replica to an existing Active-Active database in order to host the database on another cluster. This creates an additional active instance of the database on the specified cluster. </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">crdb-cli crdb add-instance --crdb-guid &lt;guid&gt; </span></span><span class="line"><span class="cl"> --instance <span class="nv">fqdn</span><span class="o">=</span>&lt;cluster_fqdn&gt;,username<span class="o">=</span>&lt;username&gt;,password<span class="o">=</span>&lt;password&gt;<span class="o">[</span>,url<span class="o">=</span>&lt;url&gt;,replication_endpoint<span class="o">=</span>&lt;endpoint&gt;<span class="o">]</span> </span></span><span class="line"><span class="cl"> <span class="o">[</span> --compression &lt;0-6&gt; <span class="o">]</span> </span></span><span class="line"><span class="cl"> <span class="o">[</span> --no-wait <span class="o">]</span> </span></span></code></pre> </div> <h3 id="parameters"> Parameters </h3> <table> <thead> <tr> <th> Parameter </th> <th> Value </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> crdb-guid </td> <td> string </td> <td> The GUID of the database (required) </td> </tr> <tr> <td> instance </td> <td> strings </td> <td> The connection information for the new participating cluster (required) </td> </tr> <tr> <td> compression </td> <td> 0-6 </td> <td> The level of data compression: 0=Compression disabled <br/> <br/> 6=High compression and resource load (Default: 3) </td> </tr> <tr> <td> no-wait </td> <td> </td> <td> Does not wait for the task to complete </td> </tr> </tbody> </table> <h3 id="returns"> Returns </h3> <p> Returns the task ID of the task that is adding the new instance. </p> <p> If <code> --no-wait </code> is specified, the command exits. Otherwise, it will wait for the instance to be added and return <code> finished </code> . </p> <h3 id="example"> Example </h3> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ crdb-cli crdb add-instance --crdb-guid db6365b5-8aca-4055-95d8-7eb0105c0b35 <span class="se">\ </span></span></span><span class="line"><span class="cl"><span class="se"></span> --instance <span class="nv">fqdn</span><span class="o">=</span>cluster2.redis.local,username<span class="o">=</span>[email protected],password<span class="o">=</span>admin-password </span></span><span class="line"><span class="cl">Task f809fae7-8e26-4c8f-9955-b74dbbd47949 created </span></span><span class="line"><span class="cl"> ---&gt; Status changed: queued -&gt; started </span></span><span class="line"><span class="cl"> ---&gt; Status changed: started -&gt; finished </span></span></code></pre> </div> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/references/cli-utilities/crdb-cli/crdb/add-instance/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/wait/.html
<section class="prose w-full py-12"> <h1 class="command-name"> WAIT </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">WAIT numreplicas timeout</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available since: </dt> <dd class="m-0"> 3.0.0 </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(1) </dd> <dt class="font-semibold text-redis-ink-900 m-0"> ACL categories: </dt> <dd class="m-0"> <code> @slow </code> <span class="mr-1 last:hidden"> , </span> <code> @connection </code> <span class="mr-1 last:hidden"> , </span> </dd> </dl> <p> This command blocks the current client until all the previous write commands are successfully transferred and acknowledged by at least the number of replicas you specify in the <code> numreplicas </code> argument. If the value you specify for the <code> timeout </code> argument (in milliseconds) is reached, the command returns even if the specified number of replicas were not yet reached. </p> <p> The command <strong> will always return </strong> the number of replicas that acknowledged the write commands sent by the current client before the <code> WAIT </code> command, both in the case where the specified number of replicas are reached, or when the timeout is reached. </p> <p> A few remarks: </p> <ol> <li> When <code> WAIT </code> returns, all the previous write commands sent in the context of the current connection are guaranteed to be received by the number of replicas returned by <code> WAIT </code> . </li> <li> If the command is sent as part of a <a href="/docs/latest/commands/multi/"> <code> MULTI </code> </a> transaction (since Redis 7.0, any context that does not allow blocking, such as inside scripts), the command does not block but instead just return ASAP the number of replicas that acknowledged the previous write commands. </li> <li> A timeout of 0 means to block forever. </li> <li> Since <code> WAIT </code> returns the number of replicas reached both in case of failure and success, the client should check that the returned value is equal or greater to the replication level it demanded. </li> </ol> <h2 id="consistency-and-wait"> Consistency and WAIT </h2> <p> Note that <code> WAIT </code> does not make Redis a strongly consistent store: while synchronous replication is part of a replicated state machine, it is not the only thing needed. However in the context of Sentinel or Redis Cluster failover, <code> WAIT </code> improves the real world data safety. </p> <p> Specifically if a given write is transferred to one or more replicas, it is more likely (but not guaranteed) that if the master fails, we'll be able to promote, during a failover, a replica that received the write: both Sentinel and Redis Cluster will do a best-effort attempt to promote the best replica among the set of available replicas. </p> <p> However this is just a best-effort attempt so it is possible to still lose a write synchronously replicated to multiple replicas. </p> <h2 id="implementation-details"> Implementation details </h2> <p> Since the introduction of partial resynchronization with replicas (PSYNC feature) Redis replicas asynchronously ping their master with the offset they already processed in the replication stream. This is used in multiple ways: </p> <ol> <li> Detect timed out replicas. </li> <li> Perform a partial resynchronization after a disconnection. </li> <li> Implement <code> WAIT </code> . </li> </ol> <p> In the specific case of the implementation of <code> WAIT </code> , Redis remembers, for each client, the replication offset of the produced replication stream when a given write command was executed in the context of a given client. When <code> WAIT </code> is called Redis checks if the specified number of replicas already acknowledged this offset or a greater one. </p> <h2 id="examples"> Examples </h2> <pre tabindex="0"><code>&gt; SET foo bar OK &gt; WAIT 1 0 (integer) 1 &gt; WAIT 2 1000 (integer) 1 </code></pre> <p> In the following example the first call to <code> WAIT </code> does not use a timeout and asks for the write to reach 1 replica. It returns with success. In the second attempt instead we put a timeout, and ask for the replication of the write to two replicas. Since there is a single replica available, after one second <code> WAIT </code> unblocks and returns 1, the number of replicas reached. </p> <h2 id="resp2-reply"> RESP2 Reply </h2> <a href="../../develop/reference/protocol-spec#integers"> Integer reply </a> : the command returns the number of replicas reached by all the writes performed in the context of the current connection. <h2 id="resp3-reply"> RESP3 Reply </h2> <a href="../../develop/reference/protocol-spec#integers"> Integer reply </a> : the number of replicas reached by all the writes performed in the context of the current connection. <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/wait/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/references/rest-api/objects/ldap_mapping/.html
<section class="prose w-full py-12 max-w-none"> <h1> LDAP mapping object </h1> <p class="text-lg -mt-5 mb-10"> An object that represents a mapping between an LDAP group and roles </p> <p> An API object that represents an <a href="/docs/latest/operate/rs/security/access-control/ldap/map-ldap-groups-to-roles/"> LDAP mapping </a> between an LDAP group and <a href="/docs/latest/operate/rs/references/rest-api/objects/role/"> roles </a> . </p> <table> <thead> <tr> <th> Name </th> <th> Type/Value </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> uid </td> <td> integer </td> <td> LDAP mapping's unique ID </td> </tr> <tr> <td> account_id </td> <td> integer </td> <td> SM account ID </td> </tr> <tr> <td> action_uid </td> <td> string </td> <td> Action UID. If it exists, progress can be tracked by the <code> GET </code> <code> /actions/{uid} </code> API (read-only) </td> </tr> <tr> <td> bdbs_email_alerts </td> <td> complex object </td> <td> UIDs of databases that associated email addresses will receive alerts for </td> </tr> <tr> <td> cluster_email_alerts </td> <td> boolean </td> <td> Activate cluster email alerts for an associated email </td> </tr> <tr> <td> dn </td> <td> string </td> <td> An LDAP group's distinguished name </td> </tr> <tr> <td> email </td> <td> string </td> <td> Email address used for alerts (if set) </td> </tr> <tr> <td> email_alerts </td> <td> boolean (default: true) </td> <td> Activate email alerts for an associated email </td> </tr> <tr> <td> name </td> <td> string </td> <td> Role's name </td> </tr> <tr> <td> role_uids </td> <td> array of integers </td> <td> List of role UIDs associated with the LDAP group </td> </tr> </tbody> </table> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/references/rest-api/objects/ldap_mapping/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/integrate/write-behind/.html
<section class="prose w-full py-12 max-w-none"> <h1> Write-behind (preview) </h1> <nav> <a href="/docs/latest/integrate/write-behind/quickstart/write-behind-guide/"> Quickstart </a> <p> Get started creating a write-behind pipeline </p> <a href="/docs/latest/integrate/write-behind/installation/"> Installation </a> <p> Learn how to install Write-behind </p> <a href="/docs/latest/integrate/write-behind/architecture/"> Write-behind architecture </a> <p> Discover the main components of Write-behind </p> <a href="/docs/latest/integrate/write-behind/configuration-guide/"> Write-behind configuration guide </a> <p> Configure write-behind to your database </p> <a href="/docs/latest/integrate/write-behind/data-transformation/"> Data transformation </a> <br/> <br/> <a href="/docs/latest/integrate/write-behind/monitoring-guide/"> Monitoring guide </a> <p> Monitor Write-behind engine and data processing jobs </p> <a href="/docs/latest/integrate/write-behind/reference/"> Write-behind reference </a> <p> Collects reference material for Write-behind </p> </nav> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/integrate/write-behind/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/develop/tools/insight/release-notes/v.2.38.0/.html
<section class="prose w-full py-12"> <h1> RedisInsight v2.38.0, November 2023 </h1> <p class="text-lg -mt-5 mb-10"> RedisInsight v2.38 </p> <h2 id="238-november-2023"> 2.38 (November 2023) </h2> <p> This is the General Availability (GA) release of RedisInsight 2.38. </p> <h3 id="highlights"> Highlights </h3> <ul> <li> Major UX improvements and space optimization for a cleaner and more organized Tree view, ensuring easier namespace navigation and faster key browsing. Additionally, in Tree view, you can now sort your Redis key names alphabetically. </li> <li> Renamed the application from RedisInsight v2 to simply RedisInsight </li> </ul> <h3 id="details"> Details </h3> <p> <strong> Features and improvements </strong> </p> <ul> <li> <a href="https://github.com/RedisInsight/RedisInsight/pull/2706"> #2706 </a> , <a href="https://github.com/RedisInsight/RedisInsight/pull/2783"> #2783 </a> Major UX improvements and space optimization for a cleaner and more organized Tree view. This includes consolidating the display of namespaces and keys in a dedicated section and omitting namespace information from key names in the list of keys. In addition, the Tree view introduces a new option to alphabetically sort Redis key names. </li> <li> <a href="https://github.com/RedisInsight/RedisInsight/pull/2751"> #2751 </a> Renamed the application from RedisInsight v2 to simply RedisInsight </li> <li> <a href="https://github.com/RedisInsight/RedisInsight/pull/2799"> #2799 </a> Automatically make three retries to establish or re-establish a database connection if an error occurs </li> </ul> <p> <strong> Bugs </strong> </p> <ul> <li> <a href="https://github.com/RedisInsight/RedisInsight/pull/2793"> #2793 </a> <a href="https://github.com/RedisInsight/RedisInsight/issues/2765"> Do not require </a> an SSH password or passphrase </li> <li> <a href="https://github.com/RedisInsight/RedisInsight/pull/2794"> #2794 </a> Prevent <a href="https://github.com/RedisInsight/RedisInsight/issues/2763"> potential crashes </a> caused by using parentheses in usernames on the Windows operating system </li> <li> <a href="https://github.com/RedisInsight/RedisInsight/pull/2797"> #2797 </a> Avoid initiating a bulk deletion or Profiler after the operating system resumes from sleep mode </li> </ul> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/develop/tools/insight/release-notes/v.2.38.0/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rc/security/private-service-connect/.html
<section class="prose w-full py-12 max-w-none"> <h1> Enable Private Service Connect </h1> <p class="text-lg -mt-5 mb-10"> Private Service Connect creates a private endpoint that allows secure connections to Redis Cloud databases without exposing your application VPC. </p> <p> <a href="https://cloud.google.com/vpc/docs/private-service-connect"> Private Service Connect </a> (PSC) creates a private endpoint that allows secure connections to Redis Cloud databases without exposing your application's <a href="https://en.wikipedia.org/wiki/Virtual_private_cloud"> virtual private cloud </a> (VPC). </p> <p> This feature is only available for Redis Cloud Pro subscriptions hosted on Google Cloud. </p> <h2 id="considerations"> Considerations </h2> <p> You can use Private Service Connect as an alternative to <a href="/docs/latest/operate/rc/security/vpc-peering/"> VPC peering </a> , or you can enable both for your subscription. </p> <p> Compared to VPC peering, Private Service Connect: </p> <ul> <li> <p> Only exposes the private endpoint instead of the entire application VPC network. </p> </li> <li> <p> Allows producer (Redis Cloud VPC) and consumer (application VPC) CIDR ranges to overlap. </p> </li> <li> <p> Has slightly higher network latency than VPC peering due to load balancing requirements. </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> Larger clusters are more likely to experience increased latency with Private Service Connect versus VPC peering. </div> </div> </li> </ul> <p> Consider using VPC peering and Private Service Connect in parallel for the following situations: </p> <ul> <li> <p> When migrating from one connectivity solution to the other. </p> </li> <li> <p> If different applications need to connect to the same database but have different latency or security requirements. </p> </li> </ul> <h2 id="setup-psc"> Set up Private Service Connect </h2> <p> To set up Private Service Connect, you need to: </p> <ol> <li> <p> <a href="#configure-psc"> Configure Private Service Connect </a> in the Redis Cloud console. </p> </li> <li> <p> <a href="#create-endpoints"> Create Private Service Connect endpoints </a> in the application VPC. </p> </li> <li> <p> From the Redis Cloud console, review and <a href="#accept-psc"> accept the Private Service Connect endpoint connection </a> . </p> </li> </ol> <h3 id="configure-psc"> Configure PSC </h3> <p> First, configure Private Service Connect in Redis Cloud: </p> <ol> <li> <p> Select <strong> Subscriptions </strong> from the <a href="https://cloud.redis.io/"> Redis Cloud console </a> menu and then select your subscription from the list. </p> </li> <li> <p> Select the <strong> Connectivity </strong> tab and then <strong> Private Service Connect </strong> . </p> </li> <li> <p> Select the <strong> Create connection </strong> button: </p> <a href="/docs/latest/images/rc/button-subscription-connectivity-psc-create-connection.png" sdata-lightbox="/images/rc/button-subscription-connectivity-psc-create-connection.png"> <img alt="Use the Create connection button to configure a new PSC endpoint." src="/docs/latest/images/rc/button-subscription-connectivity-psc-create-connection.png" width="140px"/> </a> </li> <li> <p> Read the <strong> Latency and cost impact </strong> message and select <strong> Accept and continue </strong> : </p> <a href="/docs/latest/images/rc/button-subscription-connectivity-psc-accept-continue.png" sdata-lightbox="/images/rc/button-subscription-connectivity-psc-accept-continue.png"> <img alt="Use the Accept and continue button to acknowledge PSC's impact on latency and cost." src="/docs/latest/images/rc/button-subscription-connectivity-psc-accept-continue.png" width="140px"/> </a> </li> <li> <p> For <strong> Create connection </strong> , enter the following <strong> Endpoint details </strong> : </p> <table> <thead> <tr> <th> Setting name </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <em> Google Cloud project ID </em> </td> <td> Google Cloud project ID </td> </tr> <tr> <td> <em> VPC name </em> </td> <td> Name of the VPC that hosts your application </td> </tr> <tr> <td> <em> Subnet name </em> </td> <td> Name of your VPC's subnet of IP address ranges </td> </tr> <tr> <td> <em> Endpoint name </em> </td> <td> Prefix used to create PSC endpoints in the consumer application VPC, so endpoint names appear in Google Cloud as <em> endpoint name prefix + endpoint number </em> </td> </tr> </tbody> </table> </li> <li> <p> Continue to the <strong> Add connections </strong> step: </p> <a href="/docs/latest/images/rc/button-subscription-connectivity-psc-continue.png" sdata-lightbox="/images/rc/button-subscription-connectivity-psc-continue.png"> <img alt="Use the Continue button to proceed to the Add connections step." src="/docs/latest/images/rc/button-subscription-connectivity-psc-continue.png" width="100px"/> </a> </li> <li> <p> Select either <strong> Bash Shell </strong> or <strong> PowerShell </strong> and then download or copy the provided <code> gcloud </code> script for later: </p> <a href="/docs/latest/images/rc/subscription-connectivity-psc-gcloud-script.png" sdata-lightbox="/images/rc/subscription-connectivity-psc-gcloud-script.png"> <img alt="Use the Download or Copy buttons to save the gcloud script for later use." src="/docs/latest/images/rc/subscription-connectivity-psc-gcloud-script.png" width="350px"/> </a> </li> <li> <p> Select <strong> Continue </strong> to save this endpoint configuration: </p> <a href="/docs/latest/images/rc/button-subscription-connectivity-psc-continue.png" sdata-lightbox="/images/rc/button-subscription-connectivity-psc-continue.png"> <img alt="Use the Continue button to save the PSC endpoint configuration." src="/docs/latest/images/rc/button-subscription-connectivity-psc-continue.png" width="100px"/> </a> </li> </ol> <h3 id="create-endpoints"> Create endpoints </h3> <p> Now that you have a pending Private Service Connect entry, you need to create the endpoints in your application's VPC: </p> <ol> <li> <p> If you have not already done so, <a href="https://cloud.google.com/dns/docs/set-up-dns-records-domain-name"> enable Cloud DNS </a> for your Google Cloud project. </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> Since it can take some time for the DNS changes to become active, we recommend you wait 10 minutes before running the <code> gcloud </code> script in the next steps. </div> </div> </li> <li> <p> If you already have a copy of the <code> gcloud </code> script shown earlier during the <strong> Add connections </strong> step, you can continue to the next step. </p> <ol> <li> <p> Otherwise, return to your Redis Cloud subscription's <strong> Connectivity &gt; Private Service Connect </strong> screen and select <strong> Complete setup </strong> for the pending endpoint: </p> <a href="/docs/latest/images/rc/button-subscription-connectivity-psc-complete-setup.png" sdata-lightbox="/images/rc/button-subscription-connectivity-psc-complete-setup.png"> <img alt="Use the Complete setup button if you need access to the gcloud script again." src="/docs/latest/images/rc/button-subscription-connectivity-psc-complete-setup.png" width="140px"/> </a> </li> <li> <p> Download or copy the script. </p> </li> </ol> </li> <li> <p> Use the <a href="https://cloud.google.com/sdk/gcloud"> <code> gcloud </code> CLI </a> to run the script. </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Warning: </div> To ensure the <code> gcloud </code> script configures the endpoints correctly, do not make any changes to it. </div> </div> </li> </ol> <p> The <code> gcloud </code> script creates 40 endpoints in the consumer application VPC. Each endpoint appears in Google Cloud as the configured endpoint name followed by the endpoint number. </p> <p> Redis Cloud displays this collection of endpoints as a single endpoint in the Redis Cloud console. </p> <h3 id="accept-psc"> Accept PSC connection </h3> <p> After the <code> gcloud </code> script finishes creating the Private Service Connect endpoints, you need to accept the connection in Redis Cloud: </p> <ol> <li> <p> In the Redis Cloud console, return to your subscription's <strong> Connectivity &gt; Private Service Connect </strong> screen. </p> </li> <li> <p> Find your pending endpoint connection in the list and select <strong> Accept </strong> : </p> <a href="/docs/latest/images/rc/button-subscription-connectivity-psc-accept.png" sdata-lightbox="/images/rc/button-subscription-connectivity-psc-accept.png"> <img alt="Use the Accept button to finish PSC endpoint setup." src="/docs/latest/images/rc/button-subscription-connectivity-psc-accept.png" width="100px"/> </a> </li> </ol> <h3 id="connect-db"> Connect to database </h3> <p> Once your Private Service Connect endpoint is active, you can connect your application to a database: </p> <ol> <li> <p> From your subscription's <strong> Connectivity &gt; Private Service Connect </strong> tab, select the <strong> Connect </strong> button for the active endpoint: </p> <a href="/docs/latest/images/rc/button-subscription-connectivity-psc-connect.png" sdata-lightbox="/images/rc/button-subscription-connectivity-psc-connect.png"> <img alt="Use the Connect button to retrieve PSC connection details." src="/docs/latest/images/rc/button-subscription-connectivity-psc-connect.png" width="100px"/> </a> </li> <li> <p> Select a database from the list. </p> </li> <li> <p> Copy the endpoint and use it in your application to connect to your database. </p> </li> </ol> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> Once your Private Service Connect endpoint is active, you must connect to the database from the Private Service Connect endpoint if you want to connect with Private Service connect. If you previously used the public or private endpoint to connect to your database, you must migrate any connections to the Private Service Connect endpoint. </div> </div> <h2 id="deactivate-psc"> Deactivate Private Service Connect </h2> <p> To deactivate Private Service Connect for your subscription: </p> <ol> <li> <p> Select <strong> Subscriptions </strong> from the <a href="https://cloud.redis.io/"> Redis Cloud console </a> menu and then select your subscription from the list. </p> </li> <li> <p> Select the <strong> Connectivity </strong> tab and then <strong> Private Service Connect </strong> . </p> </li> <li> <p> For each endpoint: </p> <ol> <li> <p> Select the <strong> Delete PSC endpoint </strong> button: </p> <a href="/docs/latest/images/rc/icon-psc-delete-endpoint.png" sdata-lightbox="/images/rc/icon-psc-delete-endpoint.png"> <img alt="Use the Delete PSC endpoint button to remove an endpoint." src="/docs/latest/images/rc/icon-psc-delete-endpoint.png" width="40px"/> </a> </li> <li> <p> Copy the provided <code> gcloud </code> script from the <strong> Remove endpoint </strong> dialog. </p> </li> <li> <p> Run the <code> gcloud </code> script with <a href="https://cloud.google.com/sdk/gcloud"> <code> gcloud </code> CLI </a> to delete the endpoint. </p> </li> </ol> </li> <li> <p> After you remove all endpoints, select the <strong> Actions </strong> button to see a list of available actions: </p> <a href="/docs/latest/images/rc/icon-psc-actions.png" sdata-lightbox="/images/rc/icon-psc-actions.png"> <img alt="Use the Toggle actions button to see a list of actions." src="/docs/latest/images/rc/icon-psc-actions.png" width="40px"/> </a> </li> <li> <p> Select <strong> Remove service </strong> and then <strong> Confirm </strong> : </p> <a href="/docs/latest/images/rc/button-subscription-connectivity-psc-remove-service-confirm.png" sdata-lightbox="/images/rc/button-subscription-connectivity-psc-remove-service-confirm.png"> <img alt="Use the Confirm button to deactivate Private Service Connect." src="/docs/latest/images/rc/button-subscription-connectivity-psc-remove-service-confirm.png" width="100px"/> </a> </li> </ol> <p> Once you remove all of your Private Service Connect endpoints and deactivate it, you must migrate any connections from a Private Service Connect endpoint to the public or private endpoint of your database. </p> <h2 id="limitations"> Limitations </h2> <p> Private Service Connect has the following limitations in Redis Cloud: </p> <ul> <li> <p> Although Redis Cloud supports using Private Service Connect with Enterprise clustering, you cannot use the <a href="/docs/latest/operate/rc/databases/create-database/#oss-cluster-api"> Cluster API </a> with Private Service Connect enabled. </p> </li> <li> <p> Private Service Connect is not available for clusters with Redis versions 6.2.12 and earlier. Contact <a href="https://redis.io/support"> Redis support </a> to upgrade the cluster to a compatible version or <a href="/docs/latest/operate/rc/databases/create-database/create-pro-database-new/"> create a new subscription </a> . </p> </li> </ul> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rc/security/private-service-connect/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/develop.html
<section class="prose w-full py-12 max-w-none"> <h1> Develop with Redis </h1> <p class="text-lg -mt-5 mb-10"> Learn how to develop with Redis </p> <nav> <a href="/docs/latest/develop/get-started/"> Quick starts </a> <p> Redis quick start guides </p> <a href="/docs/latest/develop/tools/"> Client tools </a> <p> Tools to interact with a Redis server </p> <a href="/docs/latest/develop/clients/"> Connect with Redis client API libraries </a> <p> Connect your application to a Redis database and try an example </p> <a href="/docs/latest/develop/data-types/"> Understand Redis data types </a> <p> Overview of data types supported by Redis </p> <a href="/docs/latest/develop/interact/"> Interact with data in Redis </a> <p> How to interact with data in Redis, including queries, triggered functions, transactions, and pub/sub </p> <a href="/docs/latest/develop/use/"> Use Redis </a> <p> A developer's guide to Redis </p> <a href="/docs/latest/develop/reference/"> Redis reference </a> <p> Specifications and protocols </p> </nav> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/develop/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/7.4/references/rest-api/requests/crdbs/updates/.html
<section class="prose w-full py-12 max-w-none"> <h1> CRDB updates requests </h1> <p class="text-lg -mt-5 mb-10"> Update Active-Active configuration requests </p> <table> <thead> <tr> <th> Method </th> <th> Path </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="#post-crdbs-updates"> POST </a> </td> <td> <code> /v1/crdbs/{crdb_guid}/updates </code> </td> <td> Modify Active-Active confgurarion </td> </tr> </tbody> </table> <h2 id="post-crdbs-updates"> Modify Active-Active configuration </h2> <pre><code>POST /v1/crdbs/{crdb_guid}/updates </code></pre> <p> Modify Active-Active configuration. </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Warning: </div> This is a very powerful API request and can cause damage if used incorrectly. </div> </div> <p> In order to add or remove instances, you must use this API. For simple configuration updates, it is recommended to use PATCH on /crdbs/{crdb_guid} instead. </p> <p> Updating default_db_config affects both existing and new instances that may be added. </p> <p> When you update db_config, it changes the configuration of the database that you specify. This field overrides corresponding fields (if any) in default_db_config. </p> <h3 id="post-request"> Request </h3> <h4 id="example-http-request"> Example HTTP request </h4> <pre><code>POST /crdbs/1/updates </code></pre> <h4 id="request-headers"> Request headers </h4> <table> <thead> <tr> <th> Key </th> <th> Value </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> X-Task-ID </td> <td> string </td> <td> Specified task ID </td> </tr> <tr> <td> X-Result-TTL </td> <td> integer </td> <td> Time (in seconds) to keep task result </td> </tr> </tbody> </table> <h4 id="url-parameters"> URL parameters </h4> <table> <thead> <tr> <th> Field </th> <th> Type </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> crdb_guid </td> <td> string </td> <td> Globally unique Active-Active database ID (GUID) </td> </tr> </tbody> </table> <h4 id="request-body"> Request body </h4> <p> Include a <a href="/docs/latest/operate/rs/7.4/references/rest-api/objects/crdb/modify_request/"> CRDB modify_request object </a> with updated fields in the request body. </p> <h3 id="post-response"> Response </h3> <p> Returns a <a href="/docs/latest/operate/rs/7.4/references/rest-api/objects/crdb_task/"> CRDB task object </a> . </p> <h3 id="post-status-codes"> Status codes </h3> <table> <thead> <tr> <th> Code </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1"> 200 OK </a> </td> <td> The request has been accepted. </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1"> 400 Bad Request </a> </td> <td> The posted Active-Active database contains invalid parameters. </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.2"> 401 Unauthorized </a> </td> <td> Unauthorized request. Invalid credentials </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5"> 404 Not Found </a> </td> <td> Configuration, instance or Active-Active database not found. </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.7"> 406 Not Acceptable </a> </td> <td> The posted Active-Active database cannot be accepted. </td> </tr> </tbody> </table> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/references/rest-api/requests/crdbs/updates/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/redisearch/redisearch-1.6-release-notes.html
<section class="prose w-full py-12 max-w-none"> <h1> RediSearch 1.6 release notes </h1> <p class="text-lg -mt-5 mb-10"> Improved performance of full-text search and aggregation queries. Support for aliasing of indices. Added a C API to embed RediSearch in other modules. Forked process garbage collection. </p> <h2 id="requirements"> Requirements </h2> <p> RediSearch v1.6.16 requires: </p> <ul> <li> Minimum Redis compatibility version (database): 4.0.0 </li> <li> Minimum Redis Enterprise Software version (cluster): 5.0.0 </li> </ul> <h2 id="v1616-june-2021"> v1.6.16 (June 2021) </h2> <p> This is a maintenance release for version 1.6. </p> <p> Update urgency: MODERATE - Program an upgrade of the server, but it's not urgent. </p> <p> Details: </p> <ul> <li> <p> Bug fix: </p> <ul> <li> # <a href="https://github.com/RediSearch/RediSearch/pull/2018"> 2018 </a> : FT.ADD REPLACE leaves fields from the previous document that are not included in the new document # <a href="https://github.com/RediSearch/RediSearch/pull/647"> 647 </a> # <a href="https://github.com/RediSearch/RediSearch/pull/1193"> 1193 </a> </li> </ul> </li> </ul> <h2 id="v1615-february-2021"> v1.6.15 (February 2021) </h2> <p> This is a maintenance release for version 1.6. </p> <p> Update urgency: Low </p> <p> Details: </p> <ul> <li> <p> Minor enhancements: </p> <ul> <li> # <a href="https://github.com/RediSearch/RediSearch/pull/1225"> 1225 </a> Allow scientific representation of numbers for numeric fields. </li> <li> # <a href="https://github.com/RediSearch/RediSearch/pull/1574"> 1574 </a> Allow SORTBY for non-sortable fields. </li> </ul> </li> <li> <p> Minor bugfixes: </p> <ul> <li> # <a href="https://github.com/RediSearch/RediSearch/pull/1683"> 1683 </a> Add a module parameter _NUMERIC_COMPRESS which prevent <nobr> double -&gt; float </nobr> compression. It prevents an issue where an exact match on some floating-point numbers is not found. </li> <li> # <a href="https://github.com/RediSearch/RediSearch/pull/1757"> 1757 </a> Remove assertion on the limitation of the number of sortable fields, instead return an error. </li> <li> # <a href="https://github.com/RediSearch/RediSearch/pull/1668"> 1668 </a> Query words from stopword list on tag fields. </li> <li> # <a href="https://github.com/RediSearch/RediSearch/pull/1745"> 1745 </a> Enforce 0 value for count reducer. </li> <li> # <a href="https://github.com/RediSearch/RediSearch/pull/1774"> 1774 </a> MINPREFIX &amp; MAXEXPANSION can be changed in runtime. </li> <li> # <a href="https://github.com/RediSearch/RediSearch/pull/1761"> 1861 </a> Fix issue for FT.SCOREEXPLAIN where reply array depth can exceed 7. </li> <li> # <a href="https://github.com/RediSearch/RediSearch/pull/1689"> 1689 </a> FT.SUGGET results from RSCoordinator are more consistent. </li> <li> Various small tweaks under the hood. </li> </ul> </li> </ul> <h2 id="v1614-september-2020"> v1.6.14 (September 2020) </h2> <ul> <li> This is a maintenance release for version 1.6. </li> </ul> <p> Details: </p> <ul> <li> <p> Minor features: </p> <ul> <li> # <a href="https://github.com/RediSearch/RediSearch/pull/1420"> 1420 </a> The hard limit of the number of results produced by FT.SEARCH is now configurable with MAXSEARCHRESULTS. </li> </ul> </li> <li> <p> Bug fixes: </p> <ul> <li> # <a href="https://github.com/RediSearch/RediSearch/pull/1313"> 1313 </a> Wrong error of unsupported phonetic field. </li> <li> # <a href="https://github.com/RediSearch/RediSearch/pull/1286"> 1286 </a> Possible crash on optional search. </li> <li> # <a href="https://github.com/RediSearch/RediSearch/pull/1449"> 1449 </a> Rare file descriptor leak on FORK GC. </li> <li> # <a href="https://github.com/RediSearch/RediSearch/pull/1469"> 1469 </a> Endless loop when reaching internal docid above uint32_max. </li> </ul> </li> </ul> <h2 id="v1613-may-2020"> v1.6.13 (May 2020) </h2> <p> This is a maintenance release for version 1.6. </p> <p> Headlines: </p> <ul> <li> This release improves overall stability and provides fixes for issues found after the previous release. </li> </ul> <p> Details: </p> <ul> <li> Bugfixes: <ul> <li> # <a href="https://github.com/RediSearch/RediSearch/pull/1186"> 1186 </a> # <a href="https://github.com/RediSearch/RediSearch/pull/1188"> 1188 </a> incorrect values for <code> inverted_sz_mb </code> and <code> num_records </code> in <code> FT.INFO </code> command. </li> </ul> </li> </ul> <h2 id="v1612-april-2020"> v1.6.12 (April 2020) </h2> <p> Headlines: </p> <ul> <li> This release improves overall stability and provides fixes for issues found after the previous release. </li> </ul> <p> Details: </p> <ul> <li> Features: <ul> <li> # <a href="https://github.com/redisearch/redisearch/issues/1172"> 1172 </a> Added <code> exists </code> function that can be used on conditional updates ( <code> REPLACE PARTIAL </code> ) to check if a field exists in the document. </li> </ul> </li> <li> Minor Enhancements: <ul> <li> # <a href="https://github.com/redisearch/redisearch/issues/1172"> 1172 </a> Lazy evaluation of the right side of 'or'/'and' clauses in IF condition. </li> <li> # <a href="https://github.com/redisearch/redisearch/issues/1134"> 1134 </a> Remove hard limit on LIMIT when using FT.SEARCH. </li> </ul> </li> <li> Bugfixes: <ul> <li> # <a href="https://github.com/redisearch/redisearch/issues/1124"> 1124 </a> NOINDEX tag fields could not be updated on UPDATE PARTIAL with no indexed fields. </li> <li> # <a href="https://github.com/redisearch/redisearch/issues/1120"> 1120 </a> Release loop in II_GetCriteriaTester which released the same criteria tester multiple times. </li> <li> # <a href="https://github.com/redisearch/redisearch/issues/1161"> 1161 </a> Case where setting <code> MAXDOCTABLESIZE </code> had no effect. </li> <li> # <a href="https://github.com/redisearch/redisearch/issues/1169"> 1169 </a> <code> FIRST_VALUE </code> reducer crashed when value did not exist. </li> <li> # <a href="https://github.com/redisearch/redisearch/issues/1159"> 1159 </a> Infinite loop on <code> NOT </code> criteria tester.% </li> </ul> </li> </ul> <h2 id="v1611-march-2020"> v1.6.11 (March 2020) </h2> <p> Headlines: </p> <ul> <li> This release improves overall stability and provides fixes for issues found after the previous release. </li> </ul> <p> Details: </p> <ul> <li> Bugfixes: <ul> <li> # <a href="https://github.com/redisearch/redisearch/issues/1126"> 1126 </a> Memory leak introduced by queries for tag fields that have no results. </li> </ul> </li> </ul> <h2 id="v1610-march-2020"> v1.6.10 (March 2020) </h2> <p> Headlines: </p> <ul> <li> This release improves overall stability and provides fixes for issues found after the previous release. </li> <li> This release fixes certain backwards compatibility issues compared to 1.4. Although they are rare cases, it is recommended when upgrading to 1.6 to use this version or newer. </li> </ul> <p> Details: </p> <ul> <li> Minor Enhancements: <ul> <li> # <a href="https://github.com/redisearch/redisearch/issues/1062"> 1062 </a> Added Custom stopwords list in <code> FT.INFO </code> </li> </ul> </li> <li> Fixed backwards incompatible issues: <ul> <li> # <a href="https://github.com/redisearch/redisearch/issues/1075"> 1075 </a> Fields should always be returned to the user as a string. </li> <li> # <a href="https://github.com/redisearch/redisearch/issues/1074"> 1074 </a> Don't truncate possible integral values when printing. </li> <li> # <a href="https://github.com/redisearch/redisearch/issues/1065"> 1065 </a> Revert "Change how generated reducer aliases are made". </li> </ul> </li> <li> Bugfixes: <ul> <li> # <a href="https://github.com/redisearch/redisearch/issues/1085"> 1085 </a> Min and max value on non leaf nodes in the numeric tree should not be updated. </li> <li> # <a href="https://github.com/redisearch/redisearch/issues/1106"> 1106 </a> Pipe leak on <code> FORK GC </code> caused by closing the fork without holding the lock. </li> <li> # <a href="https://github.com/redisearch/redisearch/issues/1114"> 1114 </a> PR # <a href="https://github.com/redisearch/redisearch/issues/986"> 986 </a> reverted the work from # <a href="https://github.com/redisearch/redisearch/issues/985"> 985 </a> , # <a href="https://github.com/redisearch/redisearch/issues/989"> 989 </a> . This PR reintroduces these features. </li> </ul> </li> </ul> <h2 id="v169-february-2020"> v1.6.9 (February 2020) </h2> <p> Headlines: </p> <ul> <li> This release improves overall stability and provides fixes for issues found after the previous release. </li> </ul> <p> Details: </p> <ul> <li> Bugfixes: <ul> <li> # <a href="https://github.com/redisearch/redisearch/issues/1052"> 1052 </a> Remove wrong optimization on Quantile. </li> <li> # <a href="https://github.com/redisearch/redisearch/issues/1057"> 1057 </a> Memory pool did not release memory when certain limit was reached. </li> </ul> </li> </ul> <h2 id="v168-february-2020"> v1.6.8 (February 2020) </h2> <p> Headlines: </p> <ul> <li> This release improves overall stability and provides fixes for issues found after the previous release. </li> </ul> <p> Details: </p> <ul> <li> Bugfixes: <ul> <li> # <a href="https://github.com/redisearch/redisearch/issues/1052"> 1052 </a> Remove wrong optimization on Quantile. </li> <li> # <a href="https://github.com/redisearch/redisearch/issues/1057"> 1057 </a> Memory pool did not release memory when certain limit was reached. </li> </ul> </li> </ul> <h2 id="v16-ga-january-2020"> v1.6 GA (January 2020) </h2> <p> This is the General Availability Release of RediSearch 1.6 (v1.6.7). </p> <p> Headlines: </p> <ul> <li> Several performance improvements increasing full-text search queries up to 60% and aggregation queries up to 73%. </li> <li> Support for aliasing of indices. </li> <li> Low-level API in C (and <a href="https://github.com/RediSearch/redisearch-api-rs"> Rust bindings </a> ) to make RediSearch embeddable in other Redis modules. <a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/deprecated-features/graph/"> RedisGraph </a> is the first GA consumer. </li> <li> Forked process Garbage Collection (FORK GC) allows for stable read latencies. </li> </ul> <p> Full details: </p> <ul> <li> <p> Added functionality </p> <ul> <li> # <a href="https://github.com/RediSearch/RediSearch/issues/658"> 658 </a> <code> FT.ADD … REPLACE … NOCREATE </code> will not add the document if the document does not exist. </li> <li> # <a href="https://github.com/RediSearch/RediSearch/issues/575"> 575 </a> Add index aliasing. This allows users to provide (or remove) ‘links’ to indexes. The commands are <code> FT.ALIASADD </code> , <code> FT.ALIASDEL </code> , and <code> FT.ALIASUPDATE </code> . </li> <li> New C API to make RediSearch embeddable in other Redis modules. This API allows other Redis modules to use functionality of RedisSearch without actually having the “module” functionality active. Note that this must still be used on Redis proper. Modules that are already incorporating this API </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/releases/tag/v2.0.1"> RedisGraph </a> GA </li> <li> <a href="https://github.com/RedisTimeSeries/RedisTimeSeries/pull/186"> RedisTimeSeries </a> (WIP) </li> <li> <a href="https://github.com/RedisJSON/RedisJSON2"> RedisJSON </a> (WIP) </li> </ul> </li> <li> <p> Performance improvements </p> <ul> <li> Improve performance when using many union (|) iterators </li> <li> Improve performance when using many intersect iterators </li> <li> Improve overall index reading performance </li> <li> # <a href="https://github.com/RediSearch/RediSearch/issues/598"> 598 </a> Do not return <code> foo: NULL </code> if <code> foo </code> is not present in the document. This conserves network bandwidth </li> </ul> </li> <li> <p> Bugfixes - Semantics </p> <ul> <li> # <a href="https://github.com/RediSearch/RediSearch/issues/688"> 688 </a> # <a href="https://github.com/RediSearch/RediSearch/issues/623"> 623 </a> Fix various issues with optional (~) search operator: <ul> <li> Fixes omitted results when using union operators in addition to optional iterators. </li> <li> Allow optional iterator to be used in isolation in promotion-only mode (without a filter query) </li> <li> Fix issue where weight attribute was being ignored </li> </ul> </li> <li> # <a href="https://github.com/RediSearch/RediSearch/issues/653"> 653 </a> FT.GET will no longer return a document as existing if it was not added by FT.ADD, even if the document exists in the server as a plain redis hash </li> <li> FT.AGGREGATE is now more stringent with its semantics, avoiding nonsensical queries or referencing fields which do not exist in the schema or LOADed. </li> <li> # <a href="https://github.com/RediSearch/RediSearch/issues/779"> 779 </a> Added <code> to_number() </code> and <code> to_str() </code> functions for ambiguity reasons </li> <li> # <a href="https://github.com/RediSearch/RediSearch/issues/906"> 906 </a> A description of how scores were calculated can be added by adding 'EXPLAINSCORE' </li> <li> # <a href="https://github.com/RediSearch/RediSearch/issues/897"> 897 </a> <code> FORK GC </code> has now lowest priority over indexing and read queries </li> <li> Added automated tests to ensure macOs build works </li> </ul> </li> <li> <p> Bugfixes - Crash/Stability </p> <ul> <li> Improved overall architectural stability </li> <li> # <a href="https://github.com/RediSearch/RediSearch/issues/666"> 666 </a> Fix crash when conflict between internal key name and user key name is encountered; e.g. creating a new document with <code> ft:two/two </code> </li> <li> # <a href="https://github.com/RediSearch/RediSearch/issues/697"> 697 </a> # <a href="https://github.com/RediSearch/RediSearch/issues/588"> 588 </a> Fix memory leaks </li> <li> # <a href="https://github.com/RediSearch/RediSearch/issues/691"> 691 </a> Fix crash on <code> FT.EXPLAIN </code> </li> <li> Proper module-level and index-level cleanup functionality </li> <li> Simplified concurrency model </li> <li> # <a href="https://github.com/RediSearch/RediSearch/issues/898"> 898 </a> Fix rare issue where <code> FORK GC </code> doesn't exists on termination of Redis </li> <li> # <a href="https://github.com/RediSearch/RediSearch/issues/865"> 865 </a> When using <code> FT.SEARCH </code> with <code> SORTBY </code> , it will only be possible to sort by one field </li> <li> # <a href="https://github.com/RediSearch/RediSearch/issues/917"> 917 </a> Fix wrong results introduced in a skip optimisation </li> <li> # <a href="https://github.com/RediSearch/RediSearch/issues/888"> 888 </a> <code> NULL </code> terms cause <code> FORK </code> GC to crash </li> <li> # <a href="https://github.com/RediSearch/RediSearch/issues/887"> 887 </a> Chinese searches not being converted to simplified Chinese. </li> <li> Fix <code> FORK GC </code> issue where read from pipe did not returned all the data </li> </ul> </li> </ul> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/redisearch/redisearch-1.6-release-notes/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> ★ </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> ★ </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> ★ </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> ★ </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> ★ </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>